Cloning a MySQL database

If you want to set up a test version of your WordPress or Drupal website, you’re probably going to need to clone your MySQL database. You don’t want to be attaching your test site to your live production database, or you’ll end up with some nasty problems.

Cloning a MySQL database can be either one of the most difficult things you can try to do, or one of the easiest, depending on how you approach it. If you search around on the Googlesphere, you’ll find lots of people trying to tell you that the only way you can make a copy of your MySQL database is by exporting it and importing it. This is one way, but it’s definitely not the best way.

Exporting and importing your database means you have to save a local copy in SQL format to your PC hard disk, then upload it again and import it using PHPMyAdmin. If you run big and complex websites like I often do, you’ll find this is frustratingly slow to do and very prone to failure due to long select statements.

So let me tell you about the easy way to clone a MySQL database.

1. Log into Cpanel

2. Select PhpMyAdmin from the Database menu

3. In PhpMyAdmin, select the database you want to clone

First, select PhpMyAdmin from the Cpanel menu

4. Select the “Operations” tab from the top menu on the right side

Select “Operations” from the tab menu

5. In the “Copy database to” tab, enter the name of your clone database

6. Select “Structure and data” and leave the other settings at default

Now copy your database to a new database

7. Click “GO”

Whee, you have a clone of your production database that you can now hack to your heart’s content. All you need to do now is set up the user permissions, hook it up to the cloned WordPress or Drupal installation and you’re on fire.

If you have any questions about this process, please don’t hesitate to post them here.


Share your thoughts on this post