一:问题描述
备份时,报错:
[root@ser6-51 ~]# mongodump -d myTest -o /backup/mongodb/all_bak_20150619.bak -u=superuser -p=123456
2015-06-29T10:17:10.784+0800 Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.
二:解决办法添加--authenticationDatabase admin
如:
[root@ser6-51 mongodb]# mongodump -d myTest -o /backup/mongodb/all_bak_20150619.bak -u superuser -p=123456 --authenticationDatabase admin
2015-06-29T10:24:21.427+0800 writing myTest.system.indexes to /backup/mongodb/all_bak_20150619.bak/myTest/system.indexes.bson
2015-06-29T10:24:21.428+0800 writing myTest.t to /backup/mongodb/all_bak_20150619.bak/myTest/t.bson
2015-06-29T10:24:21.428+0800 writing myTest.t2 to /backup/mongodb/all_bak_20150619.bak/myTest/t2.bson
2015-06-29T10:24:21.429+0800 writing myTest.t metadata to /backup/mongodb/all_bak_20150619.bak/myTest/t.metadata.json
2015-06-29T10:24:21.429+0800 writing myTest.t2 metadata to /backup/mongodb/all_bak_20150619.bak/myTest/t2.metadata.json
2015-06-29T10:24:21.468+0800 done dumping myTest.t2
2015-06-29T10:24:21.468+0800 done dumping myTest.t
--注意:指定密码时,必须在-p后添加‘=密码’,否则也会报错:error parsing command line options: expected argument for flag `-p, --password'