Posts

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...

How to Back Up and Restore MySQL Databases with Mysqldump

Mysqldump Command Syntax Before going into how to use the mysqldump command, let's start by reviewing the basic syntax. The mysqldump utility expressions take the following form: mysqldump [ options ] > file.sql Copy options  - The  mysqldump options file.sql  - The dump (backup) file To use the mysqldump command the MySQL server must be accessible and running. Backup a Single MySQL Database The most common use case of the mysqldump tool is to backup a single database. For example, to create a backup of the database named  database_name  using the user  root  and save it to a file named  database_name.sql  you would run the following command: mysqldump -u root -p database_name > database_name.sql You will be prompted to enter the root password. After successful authentication, the dump process will start. Depending on the database size, the process can take some time. If you are logged in as the same user t...