Using phpMyAdmin to copy a MySQL database
phpMyAdmin provides a simple way to duplicate a database. This is useful for creating backups, testing changes, or migrating data to a new environment.
Why Copy a Database?
Section titled “Why Copy a Database?”- Create a backup before making major changes.
- Set up a staging environment for testing.
- Duplicate data for migration to another domain or server.
Method 1: Export and Import
Section titled “Method 1: Export and Import”This is the most common and reliable way to copy a database.
Step 1: Export the Source Database
Section titled “Step 1: Export the Source Database”- Log in to cPanel → phpMyAdmin.
- Select the database you want to copy from the left sidebar.
- Click the Export tab.
- Choose Quick export method and SQL format.
- Click Go → download the
.sqlfile to your computer.
Step 2: Create a New Database
Section titled “Step 2: Create a New Database”- In cPanel → MySQL Databases, create a new database.
- Create a new user and assign it to the database with ALL PRIVILEGES.
Step 3: Import into the New Database
Section titled “Step 3: Import into the New Database”- In phpMyAdmin, select the new database.
- Click the Import tab.
- Upload the
.sqlfile you exported. - Click Go → phpMyAdmin imports all tables and data.
Method 2: Copy Within phpMyAdmin (Single Database Server)
Section titled “Method 2: Copy Within phpMyAdmin (Single Database Server)”phpMyAdmin also allows copying tables directly if both databases exist on the same server.
-
Log in to phpMyAdmin.
-
Select the source database → choose a table.
-
Click Operations tab.
-
Under Copy table to (database.table):
- Enter the destination database name.
- Choose whether to copy structure only or structure and data.
-
Repeat for each table until the database is duplicated.
- Export/Import is recommended for full database copies.
- Table‑by‑table copy is useful for partial duplication.
- Always back up before making changes.
- Large databases may take longer to export/import.