855
Comment:
|
1102
|
Deletions are marked like this. | Additions are marked like this. |
Line 5: | Line 5: |
== Login == * $ mongo 10.32.2.4 --authenticationDatabase admin --username test --password mypass * > db test * > show dbs * > use 9spokes * > db.getCollection("") * > show collections * db.getCollection("config_data").find() |
MongoDB nosql notes
Login
- $ mongo 10.32.2.4 --authenticationDatabase admin --username test --password mypass
> db
- test
> show dbs
> use 9spokes
> db.getCollection("")
> show collections
- db.getCollection("config_data").find()
Replicaset
- View members
mongo admin --host $ip -u root -p $pass -eval "rs.status()"
- Check if current server is the write
mongo admin --host $ip -u root -p $pass --quiet --eval "db.isMaster()['ismaster']"
Recover password
- stop the mongod service
- edit /etc/mongod.conf
:PRIMARY> use admin :PRIMARY> db.createUser({user:"root",pwd:"mongopwd",roles:[{role:"root",db:"admin"}]}); :PRIMARY> db.changeUserPassword("root","mongopwd")