This is the case. mongodb under Ubuntu uses everything normally. It turns on authentication. Users created by using it use everything normally and can be verified. The following information shows the three users I created. When using it, it is normally connected (nodejs connection), but when it comes to data backup, it will not work. please ask your boss for advice on what the problem is.
root@vueblog:/blog/backup# sudo mongodump -h 127.0.0.1 -d blog -u blogUser -p blogUser -o /blog/backup/
2018-07-31T02:33:44.213+0100
//said I failed to verify, look at the following, the account password is the same, and create the same user
Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.
> use admin
switched to db admin
> db.auth("blogUser","blogUser")
1 // Verification Passed
//All Administrators
> db.auth("blogAdmin","blogAdmin")
1
> db.system.users.find().pretty()
{
"_id" : "admin.blogAdmin",
"user" : "blogAdmin",
"db" : "admin",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "LezWgtwzcQdUGJNQHk/PrA==",
"storedKey" : "JMq+WDKQUM+F6psaYkJ4A64ICvc=",
"serverKey" : "wjVtJeXI+cSOkL/hRea/XMOnsHM="
}
},
"customData" : {
},
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
{
"_id" : "admin.blogUser",
"user" : "blogUser",
"db" : "admin",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "i0pAWh218NJZOg31QUw6Mg==",
"storedKey" : "NKiBdk7pjS6xfGVWfZ0+ymcBQv8=",
"serverKey" : "jN7OYs4t3NNwANlfdPfa7FMW3ug="
}
},
"customData" : {
},
"roles" : [
{
"role" : "readWrite",
"db" : "blog"
}
]
}
{
"_id" : "admin.blogSession",
"user" : "blogSession",
"db" : "admin",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "BMpvRaJAp6vb/u41AuvWHA==",
"storedKey" : "PygM60Xwykru10P2FvUcYQwkvoQ=",
"serverKey" : "2bqPumdwUOMu0491TZdxo/ujris="
}
},
"customData" : {
},
"roles" : [
{
"role" : "readWrite",
"db" : "session"
}
]
}
Try this:
sudo mongodump -h 127.0.0.1 -d blog -u blogUser -p blogUser --authenticationDatabase admin -o /blog/backup/