Differences between revisions 2 and 3
Revision 2 as of 2017-11-23 09:39:08
Size: 337
Editor: PieterSmit
Comment:
Revision 3 as of 2017-12-07 09:02:59
Size: 855
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
=== 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")
}}}
Line 14: Line 22:

  {{{
mongo admin --host 192.168.70.13 -u root -p mongopassword --eval 'rs.initiate({_id: "local_sandbox-MongoDB", members: [{_id: 0, host: "192.168.70.11:27017"},{_id: 1, host: "192.168.70.12:27017"},{_id: 2, host: "192.168.70.13:27017"}]})'

}}

MongoDB nosql notes

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)