Missing Databases in Cpanel
Recently, I came across one of the cPanel issue where a customer was complaining that the databases has suddenly disappeared from the cPanel although he did not delete any databases. After login to the server I found that the databases exists in /var/lib/mysql its just fact that they are not visible in cPanel. After a bit digging I found that with cPanel version 11.28 cPanel & WHM introduces the Database Mapping feature. A databases mapping tool allows administrators to grant ownership of databases and database users to a cPanel user. So after granting ownership to cPanel users, he/she can manage that database from the cPanel interface itself. This tool is handy when you are migrating accounts from different panels like plesk or any other. The cPanel has also designed a script for databases mapping and in case cPanel fails to use this script, databases can be missing from the cPanel.
In order to troubleshoot this issue, you need to execute database mapping script. To make sure database indeed exists in the server, you may run following command through shell. Here I am assuming that the cPanel user name is mylocal, a cPanel user name is crucial as you know database name prefix always contains cPanel user name. Anyways, you can execute following command.
ls /var/lib/mysql|grep cpanelusername
If the output of above command displays your database that indicates database exist in the server however just missing from the database mapping.
In this case, you need to make the database maps for cPanel users by running following command.
If the command runs susccessfully, it will create the map. But in my case I got error “command not found” the reason was that the cPanel version was not updated hence I run following command.
If you see message something like below it means, cPanel update is completed.
[20120928.072428] cPanel update completed
[20120928.072428] A log of this update is available at /var/cpanel/updatelogs/update.1348814235.log
[20120928.072428] Removing upcp pidfile
[20120928.072428] Completed all updates
After you need to run following command,
It should display output something like below.
info [setupdbmap] Begin setupdbmap
info [setupdbmap] Updating MySQL users
info [setupdbmap] Processing MySQL databases and database users …
info [setupdbmap] Finished with MySQL users
info [setupdbmap] Updating PostgreSQL users
info [setupdbmap] Processing PostgreSQL databases and database users …
info [setupdbmap] Finished with PostgreSQL users
info [setupdbmap] End setupdbmap
info [setupdbmap] Storing Database Index
info [setupdbmap] Database Index Complete.
Now, you can update the cpanel database cache by running the following command:
You are done!!