Mongodb's solution to forgetting your password

  • 2020-05-10 23:07:11
  • OfStack

I forgot to save the password I just set in the afternoon. I went to have dinner in the evening and forgot it when I came back. It is not difficult to find out if you have studied 1, but if you have not found it directly on the Internet, please record 1. Follow the following steps

Operation steps:


vim /etc/mongodb.conf          # Modify the mongodb The configuration, auth = true Comment it out, or change it to false
service mongodb restart        # restart mongodb service
 
mongo                          # Run client (also available mongodb Run this in the installation directory.)
use admin                      # Switch to the system account table
db.system.users.find()         # View current account (password encrypted)
db.system.users.remove({})     # Delete all accounts
db.addUser('admin','password') # Add a new account
 
vim /etc/mongodb.conf          # restore auth = true
service mongodb restart        # restart mongodb service

Original text: http: / / www. lellansin. com bf e5 / mongodb - % % % 98% af e5 b0 ae e8 % % % % % 86% a0 e7 % % 81. html


Related articles: