- mongodb备份
shell mongodump --db db_test --excludeCollection updatelog --excludeCollection sess --port 27000 --authenticationDatabase admin --username db_test --password 123 --out /root/backups/mongodump
- mongodb恢复
mongorestore -h 127.0.0.1:27000 -d yh_ga --authenticationDatabase admin --username db_test --password 123 /root/backups/yh_ga
- mongo连接
mongo 127.0.0.1:27000 --authenticationDatabase admin --username db_test --password 123
- 查看数据库
show dbs;
- 查看集合
show collectons
- 查询集合数据
db.getCollection("system").find();
- 创建用户
use admin
db.createUser(
{
user: "myUserAdmin",
pwd: "abc123",
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)