sh Mongo Cheatsheet
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Mongo Cheatsheet相关的知识,希望对你有一定的参考价值。
#Connect
mongo admin -u admin -p <current_password>
MongoClient.connect('mongodb://admin:password@localhost:27017/db')
#Change Password
db.changeUserPassword(‘admin’,’<new_password>’)
#restart
db.adminCommand({ shutdown: 1})
db.createUser(
{
user: "testUser",
pwd: "xyz123",
roles: [ { role: "readWrite", db: "test" } ]
}
)
use reporting
db.grantRolesToUser(
"reportsUser",
[
{ role: "read", db: "accounts" }
]
)
#BACKUP
mongodump --db pp_helpdesk_prd -u admin_helpdesk -p ptPP1953da --out /var/backups/pp-helpdesk/`date +"%d-%m-%y"`
#RESTORE
sudo mongorestore --db newdb --drop /var/backups/mongobackups/13-06-19/pp_helpdesk_prd/
#DELETE OLDER 30DAYS
find /var/backups/pp-helpdesk/ -mtime +30 -exec rm -rf {} \;
以上是关于sh Mongo Cheatsheet的主要内容,如果未能解决你的问题,请参考以下文章
sh 庆典-的cheatsheet
sh Nginx - Cheatsheet
sh Bash - cheatsheet
sh psql-cheatsheet.md
sh Tmux cheatsheet
sh Tmux cheatsheet