2016年4月13日 星期三

mongo note



login as Admin
mongo -u peter -p Asdf12345678 --authenticationDatabase admin


Delete whole table (collection)
db.ShareCode.drop()


Create Admin
sudo mongo admin --username root --password PASSWORD
show dibs
use admin
db.createUser
dbcreateUser({
user: "USERNAME",
pwd: "PASSWORD",
roles: ["root"]
})

mongo -u peter -p Asdf12345678 --authenticationDatabase admin


mongodump --host 23.99.110.206 --port 27017 -u peter -p Asdf12345678 --out data/backup/

Backup By mongodump
mongodump --host localhost --port 27017 -u peter -p Asdf12345678 --out data/backup/

Restore By mongorestore
mongorestore --host localhost --port 27017 -u peter -p Asdf12345678 data/backup
sudo service mongod start


Open extended connect



command:



db
use dbNAME
show dbNAME
show dbs
show tables
db.TABLES.find()
db.TABLES.find({"text":"abc"})
db.collectionsName.find()

Remove Data Directories.

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb


-The MongoDB instance stores its data files in /var/lib/mongodb 
-its log files in/var/log/mongodb by default
-runs using the mongodb user account. 
-You can specify alternate log and data file directories in /etc/mongod.conf


Error 
Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.

Answer 
export LC_ALL=C

沒有留言:

張貼留言