right I also think maybe I messed up midway and now it has become cumbersome, I will try it again.
If you are not very familiar with MongoDB then running ReplicaSet can be really tricky. There are a lot of steps to complete.
Maybe you should take a course at MongoDB University, I did a course on replication and authorization.
1 Like
I did all the steps now again and currently running in ubuntu I successfully followed all steps and last error after trying to create user in mongosh
is
admin> db.createUser(
... {
... user: "admin",
... pwd: passwordPrompt(), // or cleartext password
... roles: [
... { role: "userAdminAnyDatabase", db: "admin" },
... { role: "readWriteAnyDatabase", db: "admin" }
... ]
... }
... )
Enter password
MongoServerError[Unauthorized]: Command createUser requires authentication
admin>
you need to log in as root first
Like the sudo -i in terminal? Or something else?
run
sudo /usr/bin/percona-server-mongodb-enable-auth.sh
Wrote an article on how to run Replica Set in Docker, based on configuration
1 Like