Duplicating a WordPress database is a common task when you want to move a site to a new host, create a staging environment, or simply back up your data before making major changes. This guide shows you how to copy an entire database using phpMyAdmin, the web-based tool that most hosting control panels provide. You’ll learn the two main methods—export and import, and the “copy table” approach—plus how to fix the most frequent problems that arise.
What You’ll Need
- Access to phpMyAdmin for the source database (usually via cPanel, Plesk, or a similar control panel).
- Access to a destination database—either on the same server or a different one—where you have permission to create or import tables.
- The WordPress database name and your database username/password (you can find these in your
wp-config.phpfile). - If you’re moving to a new server, you’ll also need FTP or file manager access to upload the
wp-config.phpchanges later.
Step-by-Step
Method 1: Export and Import (Full Copy)
- Log in to phpMyAdmin for the source database. Open your hosting control panel and click the phpMyAdmin icon, or go to
yoursite.com/phpmyadminif it’s installed. - Select the database you want to duplicate from the left-hand sidebar. The name is usually something like
youruser_wpdb. - Click the “Export” tab at the top. Choose the “Quick” export method if you want a simple .sql file. For more control, choose “Custom” and ensure “Format” is set to SQL.
- Click “Go” to download the .sql file to your computer. This file contains all the tables, data, and settings of your database.
- Log in to phpMyAdmin on the destination server (or the same server if you’re creating a copy). If you’re on the same server, you can skip to step 7.
- Create a new database if needed. In the left sidebar, click “New” and enter a name (e.g.,
youruser_wpdb2). Choose utf8mb4_general_ci as the collation, then click “Create”. - Select the new database from the sidebar.
- Click the “Import” tab at the top.
- Click “Choose File” and select the .sql file you downloaded in step 4.
- Click “Go” to run the import. phpMyAdmin will execute the SQL statements and recreate the tables.
- Update the WordPress configuration (if you’re moving to a new server). Edit the
wp-config.phpfile on the destination server to use the new database name, username, and password. Also update thesiteurlandhomeoptions in the database if the domain changes—you can do this via phpMyAdmin by editing thewp_optionstable.
Method 2: Copy Table Within the Same Server
- Log in to phpMyAdmin and select the source database.
- Click the “Operations” tab at the top of the database view.
- Scroll down to the “Copy database to” section.
- Enter a new database name in the “Database name” field.
- Choose “Structure and data” to copy everything, and check “CREATE DATABASE before copying” if you want phpMyAdmin to create the new database automatically.
- Click “Go”. phpMyAdmin will create the new database and copy all tables.
- If you’re copying on the same server, you can skip the import step entirely. Just update
wp-config.phpif you’re running a second WordPress installation.
Common Mistakes
- Forgetting to update wp-config.php after copying to a new server—you’ll see a “Error establishing a database connection” message.
- Not updating the site URL when moving to a different domain. The site will still try to load old URLs, leading to broken links or redirects.
- Using the wrong collation when creating a new database. Always use utf8mb4_general_ci for WordPress to avoid character encoding issues.
- Importing into an existing database that already has tables with the same names—this can cause conflicts or overwrite data. Always import into a fresh database.
- Not checking the file size limit for uploads in phpMyAdmin. Large databases may fail to import if the file exceeds the server’s upload_max_filesize.
Tips
- Use “Custom” export and select “Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT” to make re-importing easier—this will replace any existing tables.
- Compress the export file by choosing “gzip” or “zip” in the export options. This speeds up the download and upload.
- Test the copy by visiting the new site’s URL or running a quick query in phpMyAdmin to see if the tables are populated.
- Back up the original database before making any changes, even if you’re just copying—it’s a safety net.
- If you’re moving to a new host, many hosts offer a one-click WordPress migration plugin, but phpMyAdmin is a reliable fallback.
Troubleshooting
Import fails with “#1044 – Access denied for user”
This means your database user doesn’t have permission to create tables or databases. Contact your hosting provider to grant the necessary privileges, or use the database user that was created with the database.
Import fails with “#2006 – MySQL server has gone away”
This usually happens when the .sql file is too large. Try increasing the max_allowed_packet in your MySQL configuration, or split the file into smaller parts. Alternatively, use the “Custom” export and exclude some tables (like wp_options cache) temporarily.
Site shows “Error establishing a database connection” after copying
Check wp-config.php for the correct database name, username, password, and host. If the host is localhost but the new server uses a different host (e.g., mysql.yourhost.com), update that too.
Images or links are broken after moving
This is because the site URL in the database is still the old one. Run the following SQL in phpMyAdmin on the new database (replace newdomain.com with your actual domain):UPDATE wp_options SET option_value = 'http://newdomain.com' WHERE option_name IN ('siteurl', 'home');
Also update any hardcoded URLs in posts using a search-replace tool.
Import times out
If the import script times out, increase the PHP execution time limit or use a tool like BigDump to import large files in chunks.
Frequently Asked Questions
Can I duplicate a WordPress database without phpMyAdmin?
Yes, you can use a plugin like UpdraftPlus or WP Migrate DB, or use the command line with mysqldump if you have SSH access. phpMyAdmin is just one method.
Do I need to duplicate the database if I’m only moving the WordPress files?
Yes, the database contains all your posts, pages, settings, and user data. The files alone won’t work without a corresponding database.
What is the difference between “Quick” and “Custom” export?
Quick export uses default settings and is fine for most cases. Custom lets you choose which tables to export, compression, and other options like adding DROP statements.
Can I copy just one table instead of the whole database?
Yes, you can select a table and use the “Operations” tab to copy it to another database. This is useful for restoring a single table from a backup.
Will duplicating the database affect my original site?
No, the original database remains untouched. The copy is a separate entity, so you can safely experiment with it.
Do I need to change the database prefix when duplicating?
Only if you’re running two WordPress installations on the same database. If you’re using a separate database, you can keep the same prefix (usually wp_).
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- CentOS Stream for Developers: A Practical Guide
- Hide PHP Version HTTP Header: How To
- How to Replace a Game Controller Battery Safely
- Man-Sized 3D Printer? Why You Probably Don’t Need One100.0 cm³/h
- Scroll Horizontally with Mouse Wheel by Holding Shift5.00 min/km
- iPadOS 16 Supported Devices: Full List