1. Home
  2. Docs
  3. Migration Process
  4. Migration Preparation
  5. How do I restore a MySQL from database dump?

How do I restore a MySQL from database dump?

If you’re migrating to a new server, restoring a MySQL database from a dump allows you to replicate your website or application’s data on the new environment. This is crucial for preserving functionality, maintaining data integrity, and minimizing downtime during the migration process. Here’s how to restore your MySQL database in 2 quick and effective methods:

1. Using Command-Line

Step 1: Create a New Database

Log into the system hosting the database and use MySQL to create a new database. Then, name the database exactly as the one you lost.

This step prepares an empty database where the dump file will import the data, as the dump file already contains the commands needed to rebuild the database structure and content.

Step 2: Restore MySQL Dump

To restore the database, run the following command:

mysql -u [user] -p [database_name] < [filename].sql
  • Replace [user] with your MySQL username.
  • Replace [database_name] with the name of your database.
  • Replace [filename] with the name of the dump file you’re restoring.

Make sure to include [database_name] and [filename] in the path.

It’s likely that on the host machine, [database_name] can be in a root directory, so you may not need to add the path. Please make sure that you specify the exact path for the dump file you’re restoring, including the server name (if needed).

2. Using phpMyAdmin

If you’re running phpMyAdmin backing up, restoring your MySQL database is simple.  In phpMyAdmin, the Import tool is used to restore a database.

  1. Open phpMyAdmin and navigate to the “Import” tool on the menu at the top.
  2. In the “File to Import” section, click the “Choose File” button.
  3. Use the dialog box to locate and select the dump file you want to restore.
  4. Leave the settings at their default values unless your backup was created with specific options that require adjustment.
  5. Click “Go” to start the restoration process.

In case you have any other questions, please reach out to us via:

Was this article helpful to you? No Yes

How can we help?