Tuesday 12 November 2019

Set up mongodb and create user



$> sudo apt-get install -y mongodb
$> mongo
$> use admin

Please note: only change user and password not change to role and db

$> db.createUser({ user: "admin", pwd: "pwd@123", roles: [{ role: "userAdminAnyDatabase", db: "admin" }] })
To check user auth

$> db.auth("admin", "hate2wait@123")
$> 1

create normal user

$> use db_production
$> db.createUser({ user: "myname", pwd: "anypassword", roles: [{ role: "dbOwner", db: "db_production" }] })
$> db.auth("myname", "anypassword")
$>

$> sudo nano /etc/mongodb.conf
# Turn on/off security.  Off is currently the default
#noauth = true

auth = true

Uncomment auth = true
ctrl + x



No comments:

Post a Comment

Revert last commit or second last and more....

 Git revert commit_id -m 1 this command willl revert last commit  Git revert commit_id -m 2 this command will revert second commit with same...