How to take mysql database backup and restore database in centos 7

How to take mysql database backup and restore database in centos 7

How to take mysql database backup ?

A simple way by command line to take database backup.

# mysqldump -u {username} -p {password}  database_name > database_name.sql

  Explain parameters.

          {username} -  mysql username

          {password} - mysql password

          {db_name} - database name that you want to take backup

          {db_name.sql} - name of backfile you want to generate

If you want to see all databases name login mysql in command line.

>mysql

 #show databases;

How to take all databases backup in single command?

IF you 5 database you want to take all databases backup in single term.

 #mysqldump -u root -p password --all-databases > all_database.sql

How to take single database backup command line?

if you want to take singal database backup.

#mysqldump -u root -p password database_name > database_name.sql

How to take db backup in particular directory or folder ?

if you want to take backup in particular directory or folder here am using

/mnt/backup folder.

#mysqldump -u root -p password database_name > /mnt/backup/database_name.sql

How to take backup with compressed file .tgz?

if you want to take backup with compressing file you must install .zip or .tar

in your system.

#mysqldump -u root -p password database_name > database_name.sql.tgz

How to take backup AWS ec2-instance in putty?

to take aws ec2 instance backup throught putty or remote you must have

ec2-insance hostname or .pem file.

#ssh -i /path/of/pemfile/name.pem -h ec2-user@ec2-192-168-2-1.compute-1.amazonaws.com

 

mysqldump -h yourdomain.com -u root-p password db_name > db_name.sql

How to restore mysql database backup in terminal?

First of all we need to go path of database backfile

#mysql -u root -p password database_name < database_name.sql

 

Thanks for visit our blog. if you have any query comment below.

Blog type: 

Add new comment

Authored By

Sandeep Gurjar

Hy all, This is Sandeep Gurjar am the founder of hostingride.in. I am a Redhat Certified Engineer (RHCE) / AWS Solutions Architect-Associate and working as an system administrator since 2016.

Follow us on

Facebook​  Twitter  LinkedIn  Google+