A WooCommerce site running under cPanel account oldcorp needs to move to a new account newcorp on the same WHM server — same data, same MariaDB, different owner. The naive approach is RENAME DATABASE (which MySQL doesn’t support anyway), or rename the underlying directory. Both break cPanel’s user mapping because the prefix is baked into the name: oldcorp_woo cannot just become newcorp_woo — oldcorp_woo lives in oldcorp’s dbmap, and any GRANT that references it points at users that don’t exist for newcorp. The migration needs a dump and reload, with the dbmap and the user permissions reconciled at each step.
What’s happening
cPanel’s per-account database registry tracks which user owns which database. Moving a database between accounts means:
- Dumping the data from the old database.
- Creating a new database under the new account (with the new prefix).
- Loading the data into the new database.
- Creating a new user under the new account and granting it.
- Updating the application to use the new database name and user.
- Optionally, removing the old database under the old account.
Skipping step 5 leaves the application connecting to a database that’s still owned by oldcorp while newcorp’s dbmap shows nothing. The cPanel UI shows different states for both accounts, and the next backup picks up the wrong copy.
How to verify
whmapi1 list_dbs user=oldcorp
whmapi1 list_dbs user=newcorp
mysql -e "SELECT TABLE_SCHEMA, COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA='oldcorp_woo' GROUP BY TABLE_SCHEMA"
mysql -e "SELECT User, Host FROM mysql.user WHERE User LIKE 'oldcorp\\_%' OR User LIKE 'newcorp\\_%'"
du -sh /var/lib/mysql/oldcorp_woo /var/lib/mysql/newcorp_woo 2>/dev/null
df -h /var/lib/mysql
The dbmap state before. The data state on disk. The user lists for both accounts. The disk free check because for a brief window you’ll have both copies.
The fix
- Pre-create the new database under the new account so cPanel registers it correctly:
This createsuapi --user=newcorp Mysql create_database name=woonewcorp_wooand adds it tonewcorp’s dbmap. - Create the new user under the new account:
uapi --user=newcorp Mysql create_user name=woo password='new-strong-password' uapi --user=newcorp Mysql set_privileges_on_database user=newcorp_woo database=newcorp_woo privileges=ALL - Dump the old database:
mysqldump --single-transaction --routines --triggers --events --hex-blob --default-character-set=utf8mb4 oldcorp_woo > /tmp/woo-migration.sql - Load into the new database:
mysql newcorp_woo < /tmp/woo-migration.sql - Update the application config in
newcorp’s home directory. For WordPress,wp-config.php:DB_NAME = 'newcorp_woo' DB_USER = 'newcorp_woo' DB_PASSWORD = 'new-strong-password' DB_HOST = 'localhost' - Verify the application works under the new account before touching the old database. Hit the site (which is now under
newcorp’s document root), confirm reads and writes. - Update any references to the old database name in the application code. For WordPress, search wp-content for hard-coded references to the old prefix (rare in core, common in custom plugins).
- Remove the old database after a confidence period (24–48 hours) and after confirming backups of the new database are running:
uapi --user=oldcorp Mysql delete_database name=woo uapi --user=oldcorp Mysql delete_user name=woo - Verify dbmap consistency for both accounts:
whmapi1 list_dbs user=oldcorp # should not show woo whmapi1 list_dbs user=newcorp # should show newcorp_woo /scripts/dbmap_check
For multi-account hosts where database ownership changes are routine (mergers, account splits, ownership transfers), Stack Harbor’s cPanel server administration team scripts the dump-restore-reconcile sequence per pair with the dbmap verification baked in.