How do I duplicate a MySQL database?
The phpMyAdmin tool can be used to export and import databases up to a few MB in size, providing a simple way to duplicate a copy of a database using a different name on our servers.
(Remember that we already make daily MySQL backups — you only need to follow the instructions on this page if you truly need to duplicate a database under a different name.)
On this page:
- Exporting a copy of the database to your computer
- Importing the copy into a new database
- Having trouble?
- Can I use the phpMyAdmin "synchronize" feature instead?
- Using the command line for larger databases
Exporting a copy of the database to your computer
- Login to the database that you want to duplicate using phpMyAdmin
- Click the database name on the left-hand side of the page. (Don't skip this step — if you continue to step 3 before doing this, you won't be able to reload the database under a new name later.)
- Select the Export tab
- Select the Save as file option
- Click Go
You'll then be prompted to save the database file on your personal computer.
Importing the copy into a new database
You'll first need to create the new, empty database on our servers using the account control panel. After the new database has been created:
- Login to the new database using phpMyAdmin
- Click the database name on the left-hand side of the page
- Select the Import tab
- Click the Browse button under "File to import", then select the database file from your computer
- Click Go to import the database
Having trouble?
If you get an "Access denied" error when you import the database, it's probably because you forgot to click the database name in step 2 of the export.
If you see a "No database selected" error when you import the database, it's probably because you forgot to click the database name in step 2 of the import.
Can I use the phpMyAdmin "synchronize" feature instead?
The phpMyAdmin "synchronize" feature is another way of doing this that will usually work (and is sometimes faster). You can use that feature if you feel comfortable with it, although it's a little more complicated.
Using the command line for larger databases
If the database is more than a few MB in size, phpMyAdmin may have problems importing the file. In that case, advanced users can bypass phpMyAdmin completely using the command line shell, which is much more reliable.
For example, if you have database called customers that you want to copy to new_customers, you would first create a "database dump" file using:
mysqldump -u customers -p customers > customers.dump
Then you'd login to the control panel and create the new MySQL database and run this command to import the dump file, specifying the login details for the new database:
mysql -u new_customers -p new_customers < customers.dump
If you're not comfortable using the shell, please contact us and we'll be glad to do it for you.
