The recent database server is somewhat unstable, has encountered the hacker's harassment, MongoDB's security has some loopholes. The first task is to add an account to the database. Before everyone was accustomed to MongoDB without security account and password to connect to the database, then the problem is to add a security account, some are to change the adjustment.
I am using the MongoDB 3.0 version. Examples of MongoDB create account commands are as follows:
UseAdmindb.createuser ({User: "Admin", pwd: "12345678", Roles:[{role: "Useradminanydatabase", DB: "admin"}] }) UseGourmetdb.createuser ({User: "Game", pwd: "12345678", Roles:[{role: "ReadWrite", DB: "Gourmet"}] })
After the addition succeeds, executes, returns 1 which is the successful authentication.
Use Gourmetdb.auth ("Game", "12345678");
To summarize:
This is done when the MongoDB command is executed separately later:
Mongo
Use database name
Use AUTH to authenticate your account and password
Db.auth ("Game", "1234567");
Now, here's your order.
Add a security account to the MongoDB database