Thursday, 26 April 2018

How to restore Database Backup in MySQL



If we have a saved MySQL database taken using mysqldump script, use the following command to restore the backup in MySQL database.


Syntax to restore database:

[root@linuxcnf ~]# mysql -u [username] –p [password] [dbname] <  bkp_filename.sql

Example to restore a database dump in MySQL:

This example restore the backup in test_db database that’s should be already created on the MySQL Database otherwise need the create database as below.

[root@linuxcnf ~]# mysql -u root –ppassword

mysql> create database test_db;
Query OK, 1 row affected (0.03 sec)
mysql>\q
Bye
[root@linuxcnf ~]# mysql –u [username] –p [passowrd] test_db < test_db.sql
[root@linuxcnf ~]# 

Database restoration is done!!!

No comments:

Post a Comment