![]() We have to specify the authentication database to allow database users to log in via shell. # Save and exit the editor by pressing Ctrl + O -> Enter, Ctrl + XĪlso, update the alias by updating the ~/.zshrc as shown below.Īlias mongod="/usr/local/mongodb/bin/mongod -config /usr/local/mongodb/nf"Īfter enabling the authorization, we can connect to MongoDB via MongoDB Shell by executing it with options as shown below. The MongoDB server in the image listens on the standard MongoDB port, 27017, so connecting via Docker. Next, we will create the configuration file and update mongod alias to use the configuration file. Connect to MongoDB from another Docker container. This is how we can add admin users to the admin database and assign a role to the user. Now we will add the user admin with root role to the admin database using the commands as shown below.ĭb.createUser( ) We can see that MongoDB has already created three databases i.e. Start MongoDB server and MongoDB Shell using the aliases created by us in the previous steps. In this step, we will add the default admin user with root privileges and also enable Access Control to allow authenticated users. ![]() Save and exit the editor using the commands Ctrl + o -> Enter and Ctrl + x. Sudo mv mongosh-1.1.1-darwin-圆4 /usr/local/mongoshĪlso, add an alias by updating the ~/.zshrc as shown below.Īlias mongod="/usr/local/mongodb/bin/mongod -dbpath /System/Volumes/Data/data/db"Īlias mongo="/usr/local/mongodb/bin/mongo"Īlias mongosh="/usr/local/mongosh/bin/mongosh" Now install mongosh by following the same steps as we did for MongoDB using the commands shown below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |