我正在嘗試備份 mongo 資料庫,但我不斷收到身份驗證錯誤。我給了我的用戶我可以的所有權限,但我仍然無法進行備份:
# mongosh --host 10.1.10.1 --port 27017 -u administrator admin --quiet --eval "db.getUsers();"
Enter password: ************************************
{
users: [
{
_id: 'admin.administrator',
userId: UUID("52befffa-7fa9-4ab9-9325-3dfdead28f20"),
user: 'administrator',
db: 'admin',
roles: [
{ role: 'userAdminAnyDatabase', db: 'admin' },
{ role: 'restore', db: 'admin' },
{ role: 'readWriteAnyDatabase', db: 'admin' },
{ role: 'root', db: 'admin' },
{ role: 'backup', db: 'admin' }
],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
},
{
_id: 'admin.project-12',
userId: UUID("375a91b7-8c27-4d1d-8d02-ba04faaa94ce"),
user: 'project-12',
db: 'admin',
roles: [ { role: 'readWrite', db: 'project-12' } ],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
}
],
ok: 1
}
# mongodump --host 10.1.10.1 --port 27017 -u administrator --archive=test-1 --db=project-12
Enter password:
2022-05-12T18:01:55.677 0200 Failed: can't create session: could not connect to server: connection() error occured during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
我究竟做錯了什么?
uj5u.com熱心網友回復:
您需要指定身份驗證資料庫,例如
mongodump --host 10.1.10.1 --port 27017 -u administrator --authenticationDatabase=admin ...
在mongosh身份驗證資料庫上默認為您連接的資料庫。嘗試保存到 mongodb 時請參閱身份驗證失敗
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/474011.html
標籤:mongodb
