HW 1.3 - localhost exception

Started the first replica set member using -

vagrant@database:~$ mongod --replSet m310-repl --dbpath /home/vagrant/M310-HW-1.3/r0 --logpath /home/vagrant/M310-HW-1.3/r0/mongodb.log --port 31130 --sslMode requireSSL --clusterAuthMode x509 --sslPEMKeyFile /home/vagrant/shared/certs/server.pem -sslCAFile /home/vagrant/shared/certs/ca.pem --fork

Connected to this mongod using -

vagrant@database:~$ mongo --ssl --sslPEMKeyFile /home/vagrant/shared/certs/client.pem --sslCAFile /home/vagrant/shared/certs/ca.pem --host database.m310.mongodb.university --port 31130

I can’t run rs.initiate() to become the primary so I can create the user account. How can I connect using the localhost exception in this case ?

ongoDB Enterprise > rs.initiate()
“ok” : 0,
“errmsg” : “not authorized on admin to execute command { replSetInitiate: undefined }”,
“code” : 13
MongoDB Enterprise >

Welcome @ellis4008

You most likely already used that host and port to create the first user. Suggest you kill that process, empty the r0 sub directory and restart the mongod process.

PS: It’s against forum guidelines to post possible answers to labs so I’d suggest that you edit your post and redact the mongod and mongo commands.

1 Like

Hi @ellis4008,

I would also recommend you to re-check the command line options for running mongod process.