blog

Home / DeveloperSection / Blogs / Restoring MySQL Database

Restoring MySQL Database

Uttam Misra7714 23-Sep-2011

For restoring MySql databse you should follow two steps:

Create an appropriately named database on the target machine

Load the file using the mysql command:

$ mysql -u [username] -p[password] [db_to_restore] < [backupfile.sql]

Have a look how you can restore your Article_backup.sql file to the Tutorials database.

$ mysql -u admin -p Articles < Article_backup.sql

To restore compressed backup files you can do the following:

gunzip < [backupfile.sql.gz] | mysql -u [username] -p[password] [dbname]

If you need to restore a database that already exists, you'll need to use

mysqlimport command. The syntax for mysqlimport is as follows:

mysqlimport -u [username] -p[password] [databasename]
[backupfile.sql]

Updated 18-Sep-2014
More than 18 years of working experience in IT sector. We are here to serve you best.

Leave Comment

Comments

Liked By