Differences between revisions 3 and 4
Revision 3 as of 2017-12-07 09:02:59
Size: 855
Editor: PieterSmit
Comment:
Revision 4 as of 2018-11-12 00:36:58
Size: 1102
Editor: PieterSmit
Comment:
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")

MongoDb (last edited 2020-07-24 00:29:21 by PieterSmit)