---
title: "Restoring MySQL Database"  
description: "For restoring MySql databse you should follow two steps:Create an appropriately named database on the target machineLoad the file using the mysql comm"  
author: "Uttam Misra"  
published: 2011-09-23  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/241/restoring-mysql-database  
category: "database"  
tags: ["database"]  
reading_time: 1 minute  

---

# Restoring MySQL Database

For restoring MySql databse you should follow two steps:

Create an appropriately named [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) on the target machine

Load the file using the mysql [command](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net):

$ mysql -u [[username](https://www.mindstick.com/forum/12798/there-is-no-viewdata-item-of-type-ienumerable-selectlistitem-that-has-the-key-username)] -p[[password](https://www.mindstick.com/blog/118/retriving-user-password-by-using-stored-procedure-in-asp-dot-net)] [db_to_restore] < [backupfile.sql]

Have a look how you can [restore your](https://answers.mindstick.com/qa/50476/how-to-restore-your-iphone-x-from-a-backup-in-cloud) Article_backup.sql file to the Tutorials database.

$ mysql -u admin -p [Articles](https://www.mindstick.com/articles/12872/how-to-write-articles-of-50-and-more-a-day-quick-and-easy) < Article_backup.sql

To restore compressed [backup](https://www.mindstick.com/interview/1205/what-is-the-command-to-take-backup-and-restore-for-sharepoint-site) 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](https://www.mindstick.com/forum/34205/emailid-already-exists), you'll need to use

mysqlimport command. The syntax for mysqlimport is as follows:

##### mysqlimport -u [username] -p[password] [databasename]

##### [backupfile.sql]

---

Original Source: https://www.mindstick.com/blog/241/restoring-mysql-database

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
