By default, MongoDB does not need to enter the User and password, so the client can log on. This security problem is serious. There are also many examples on the Internet, but there are also a lot of details
By default, MongoDB does not need to enter the User and password, so the client can log on. This security problem is serious. There are also many examples on the Internet, but there are also a lot of details
By default, MongoDB does not need to enter the User and password, so the client can log on. This security problem is serious.
There are also many examples on the Internet, but there are also many details that many people have not noticed me here by the way.
The following describes how to set the user name and password.
When adding a user, you must
1. If you have the relevant permissions (I will talk about it later)
2. When -- auth is not added to mongod. (If the permission is added, the following situations may occur if you add the permission)
Therefore, when adding a user, we must first add a super admin when -- auth is not added.
After the service is started, enter./mongo
In this way, it indicates that the permission has been successfully created. Then, let's try the permission.
Without -- auth, you can access admin's two favorite default tables.
> Db. system. users. find ()
Created successfully.
Add the -- auth option to the service.
Go to./mongo.
You can see that you have no access permission.