Mongo 备份数据库和还原
备份
mongodump -h IP --port 端口 -u 用户名 -p 密码 -d 数据库 -o 文件存在路径
如果想导出所有数据库,可以去掉-d
还原
mongorestore -h IP --port 端口 -u 用户名 -p 密码 -d 数据库 --drop 文件存在路径
报错 Authentication failed
加上这个参数 --authenticationDatabase admin
mongodump -h IP --port 端口 -u 用户名 -p 密码 -d 数据库 -o 文件存在路径
如果想导出所有数据库,可以去掉-d
mongorestore -h IP --port 端口 -u 用户名 -p 密码 -d 数据库 --drop 文件存在路径
加上这个参数 --authenticationDatabase admin