Databases: Copying, Renaming, Merging, Exporting, and Importing

Copying

  1. In cPanel, select "phpMyAdmin"
  2. In phpMyAdmin, select the database you intend to copy.
  3. Click the "Operations" tab.
  4. Find and select "Copy database to".
  5. Enter the name of the new database (the copy).
  6. Select "structure and data" - this will copy everything in the database. If you do not want the data, select "structure only".
  7. Put a checkmark in the box marked "CREATE DATABASE before copying".
  8. Put a checkmark in the box marked "Add AUTO_INCREMENT value".
  9. Click "Go".

 



Renaming

  1. In cPanel, select "MySQL Databases".
  2. Find the database you wish to rename in the list of Current Databases.
  3. Take note of the user already assigned to the database.
  4. Open phpMyAdmin.
  5. Select the database you wish to rename.
  6. Select the "Operations" tab. 
  7. Enter the new database name in the field titled "Rename database to".
  8. Click "Go".
  9. When phpMyAdmin confirms, verify the name is spelled correctly and click "OK".
  10. When prompted to reload the database, click "OK".

Now you need to reconfigure the user permissions for the database.

  1. Go back to "MySQL Databases".
  2. Find the database from the list under "Add User To Database"
  3. Choose the user from the list.
  4. Select "Add".
  5. Put a checkmark in the "All Privileges" box.
  6. Click "Make Changes"

Now you must update all scripts or applications which reference the database with the correct name.



Merging


Both databases that you intend to merge must be on the same account.
In cPanel

  1. Click phpMyAdmin.
  2. Click "SQL" at the top.
  3. Underneath "Run SQL query/queries on server "localhost"", insert this code: "INSERT INTO DB1.TABLE1 SELECT * FROM DB2.TABLE1". Replace DB1 and DB2 with your database names, and TABLE1 with the name of the table you are trying to merge.
  4. Click "Go".

SSH/Shell

  1. From SSH, type the command to access mysql, "mysql -u MYNAME -pPASS", replacing MYNAME and PASS with your username and password.
  2. Now enter this command, again replacing DB1, DB2, and TABLE1 with the names of your databases and the table you wish you merge. "INSERT INTO DB1.TABLE1 SELECT * FROM DB2.TABLE1;"
  3. repeat for any other tables you wish to merge.

Note: If you wish to have the data in DB2 overwrite the data in DB1 and they share a primary/unique key, use "REPLACE INTO" rather than "INSERT INTO"



Exporting


  1. In phpMyAdmin, select an existing database.
  2. Click "export", at the top.
  3. Select "Save as file" and click "Go". An .sql file will be downloaded to your computer.

 



Importing


  1. In phpMyAdmin, select "Import".
  2. Browse for the .sql file on your computer, and select it.
  3. Click "Go".

If you have any issues, there is a more in-depth article about importing in the knowledgebase.

  • 46 Users Found This Useful
Was this answer helpful?

Related Articles

Do you offer password protected directories?

By default, cPanel allows you to password protect directories in your account that you wish to...

Why can't I log into my cpanel or webmail?

There various issues that you may not be able to login to your cPanel or WebMail. We have...

Custom Error Pages

Creating your own error pages can be accomplished through cPanel. After logging in, under...

Requesting a New cPanel Password

Resetting Your cPanel PasswordYou can reset your cPanel password from the cPanel login screen....

Secure cPanel Login

Using Shared SSL to Access cPanel Use https, enter your site's IP address, and the secure port...