The first thing every cPanel account inherits when you create a MySQL database is the username prefix. An account called acmecorp that asks for a database named wp gets acmecorp_wp on disk, and every grant, dump, and connection string downstream has to use the prefixed form. Most of the database-creation tickets we see are not “I can’t create a database” — they are “I created a database and now the application can’t find it.”
What’s happening
cPanel enforces the prefix at MySQL grant time, not at name selection. The MySQL UI in cPanel will let you type wp and quietly create acmecorp_wp. The phpMyAdmin sidebar shows the prefixed name. mysql -u acmecorp_wp -p connects fine. But the application’s wp-config.php says DB_NAME=wp, and the connection fails because acmecorp does not have grants on a database called wp — that database doesn’t exist on the server. The same trap exists for usernames: acmecorp_wp is a user; wp is a user that doesn’t exist as far as your account is concerned.
The prefix length also matters. cPanel reserves 8 characters for the account name plus an underscore, so the practical limit for the database short name is 56 characters in MariaDB 10.x and 55 in older MySQL. Long Magento or WordPress staging names hit this ceiling.
How to verify
From the cPanel host as root:
whmapi1 list_dbs user=acmecorp
mysql -e "SHOW DATABASES LIKE 'acmecorp\\_%'"
mysql -e "SELECT User, Host FROM mysql.user WHERE User LIKE 'acmecorp\\_%'"
The first lists what cPanel thinks the account owns; the second lists what MySQL actually has on disk; the third lists the prefixed users. If whmapi1 and SHOW DATABASES disagree, the cPanel database map is out of sync — see the dbmaprepair runbook before doing anything else.
The fix
- Create from the API, not the UI, when you’re scripting onboarding:
uapi --user=acmecorp Mysql create_database name=wpreturns the full nameacmecorp_wpin the response. Capture it and pass it forward. - Always use the prefixed name in application config.
DB_NAME=acmecorp_wp,DB_USER=acmecorp_wp, never the short form. - For grant assignment:
uapi --user=acmecorp Mysql set_privileges_on_database user=acmecorp_wp database=acmecorp_wp privileges=ALL. cPanel will refuse if either name is not prefixed for that account — the error isAccess denied for user, which sends people debugging passwords instead of names. - When migrating in from a non-cPanel host, rename the source database to the prefixed form before import, or use
sed -i 's/olddbname/acmecorp_wp/g'on the dump. Importing a non-prefixed dump into a cPanel account and then trying to GRANT after the fact is a dead end — cPanel won’t let you grant a non-prefixed user against any database.
For multi-account hosts where database naming has drifted, Stack Harbor’s WHM server management team audits prefix compliance and rebuilds the dbmap before it bites you in a restore.