How to take backup of MySQL database using mysqldump utility and restore MySQL databsse from backup on linux system


Backup Mysql Database & Restore Mysql Database | In this tutorial we learn how to take backup of mysql database and import mysql dump on the linux system. Backup and restoration job is very important for a Database Administrator.

Backup MySQL database using mysqldump utility

To backup MySQL database we have to select the database name which database we want to take backup.After selecting the database we need to execute the below command to take backup of MySQL database.
This backup is the logical backup which is stored the data inside the linux filesystem.

Lets take an example to demonstrate how to take backup mysql database along with mysqldump example.

In my case we select “techrideradmin” database and there is one table named “student” inside the database. We want to take backup the “techrideradmin” database. After taking the backup we delete the table which is student and then restore the table using the backup file which is stored inside the linux file system.

[root@localhost ~]#  mysqldump -u root -p techrideradmin > /backup/backup-$(date +%F).sql
Enter password:

We can list the backup file which we have taken using the below command.

[root@localhost ~]# cd /backup/
[root@localhost backup]# ls
backup-2019-01-15.sql
How to take backup of MySQL database using mysqldump utility and restore MySQL backup on linux system,backup mysql database,import mysql dump
How to take backup of MySQL database using mysqldump utility and restore MySQL backup on linux system 
After enter the password backup will be completed. In the above command –u define which user is taking backup or which user has permission taking the backup and –p define the password of the user.

Restore MySQL database from the backup file

To restore the database using import mysql dump we need to create the MySQL database. After creating the database we need to execute the below command to restore the database from  the backup file.
[root@localhost ~]# mysql -u root -p techrideradmin < /backup/backup-2019-01-15.sql
Enter password:

After executing the above command we can restore the techrideradmin database smoothly.

That’s all. If this tutorial is helpful to know about Backup Mysql Database and import mysql dump please share it!

SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

1 comments: