My connection to replica set is not working

I tried to connect using this commands but gives me syntax error

mongo --host “m103-repl/mongodb://” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”

mongo --host “m103-repl/localhost:27001” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”

Would you include a screenshot showing your input and the exact error please?

bash-4.4# mongod -f mongod_1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 345
child process started successfully, parent exiting
bash-4.4# mongo --port 27001
MongoDB shell version v4.0.5
connecting to: mongodb://
Implicit session: session { “id” : UUID(“1ecc6044-557c-42f8-ae56-7096965dae6f”) }
MongoDB server version: 4.0.5
Welcome to the MongoDB shell.
For interactive help, type “help”.
For more comprehensive documentation, see
Questions? Try the support group

“info2” : “no configuration specified. Using a default configuration for the set”,
“me” : “localhost:27001”,
“ok” : 1
m103-repl:OTHER> use admin
switched to db admin
m103-repl:PRIMARY> db.createUser({ user: “m103-admin”, pwd: “m103-pass”, roles: [ { db: “admin”, role: “root” } ]})
Successfully added user: {
“user” : “m103-admin”,
“roles” : [
“db” : “admin”,
“role” : “root”
m103-repl:PRIMARY> mongo --host “m103-repl/localhost:27001” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”
2020-12-29T23:35:51.732+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:8

m103-repl:PRIMARY> mongo --host “m103-repl/localhost:27001” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”

should be executed in the bash shell, not the mongo shell.

Quit out and rerun.

FYI: The bash shell indicates > bash-4.4# on the prompt (we are running as root, so the # and 4.4 is the bash binary version).

1 Like

thank you so much! it worked

1 Like