Official Installation Guide
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Security Configuration
The default MongoDB configuration bind the server to localhost but does not have any security. To enable security:
1. Start MongoDB without security
sudo systemctl start mongod
2. Create an admin user (see Enable Access Control) in mongo shell
use admin db.createUser({ user: "cysun", pwd: "abcd", roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] })
3. Edit /etc/mongod.conf to add the following:
security: authorization: enabled
and to allow remote access, change bindIp to 0.0.0.0.
4. Create additional database and user in mongo shell
use admin db.auth("cysun", "abcd") use student db.createUser({ user: "student", pwd: "abcd", roles: ["dbOwner"] })
Also see mongo.js in cs3-scripts for how to create additional databases/users using MongoDB Node.js client.
Last Updated: 10/26/2020 10:45
Views: 31