Posts

Showing posts with the label mongodb commands

mongodb commands

install only mongodb community  version 6 and above mongo commands, sudo systemctl start mongod sudo systemctl enable mongod sudo systemctl restart mongod for backup:- $ mongodump --db healyosdb --out /home/ec2-user/mongobackup/`date +"%m-%d-%y"` to restore database mongorestore  --host localhost -d SAMPLE_VMS --port 27017 /home/vms.krishit/web/vms.krishit.com/public_html/VMS here SAMPLE_VMS is dbname creating  and VMS folder contains the db creating user with pass  use hrms_prod                db.createUser(  {    user: "hrms_prod",    pwd: passwordPrompt(),      roles: [       { role: "readWrite", db: "hrms_prod" }    ]  } ) //use cmd is important Enter password:  Successfully added user: { "user" : "hrms_prod", "roles" : [ { "role" : "readWrite", "db" : "hrms_prod" } ] } username is mongoAdmin password is h44qEBAXqs2 rol...