Knowledgebase

Migrating a Database Between Hosts Print

  • developersgitdeployment, developers, database, migration, troubleshooting, cpanel, domain, phpmyadmin, wordpress, woocommerce
  • 0

Moving data without losing any.

THE PROCEDURE

  1. Export the source database with mysqldump, or phpMyAdmin for a small one.
  2. Create the destination database and user, granting privileges.
  3. Import the dump.
  4. Update the application configuration with the new credentials, remembering the cPanel prefix.
  5. Run a search and replace if the domain changed.
  6. Verify.

THE PREFIX

Database and user names on cPanel carry your username as a prefix. A dump from another host has different names, and the application configuration must be updated to match the new ones.

FOR LARGE DATABASES

Use the command line. phpMyAdmin will time out.

Compress the dump for transfer.

SEARCH AND REPLACE

If the domain changed, URLs stored in the database must be updated. For WordPress, use a tool that handles serialised data; a raw SQL replace corrupts it.

FOR A SITE STILL TAKING ORDERS

Freeze writes during the final sync, or orders placed after your copy are lost.

VERIFYING

Compare row counts on key tables. Then test the application properly.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot