Home > AI > Database > MongoDB >

change password

Step 1, stop auth if existed

Mac

vi  /usr/local/etc/mongod.conf

comment these two lines.

# security:
#     authorization: enabled

Step 2, restart mongodb

Mac – brew

$ brew services list
$ brew services restart mongodb-community

CentOS

$ sudo service mongod start
$ sudo service mongod restart
$ sudo service mongod stop

Step 3, modify the password

$ mongo
Mongo > use admin
Mongo > db.changeUserPassword("accountUser", passwordPrompt())

Step 4, login with the password

Leave a Reply