~2 min read • Updated Feb 18, 2026
1. Delete a MySQL Database
To manually delete a MySQL database on a cPanel & WHM server, follow these steps:
- Log in to WHM as the
rootuser. - Navigate to
SQL Servicesand clickphpMyAdmin. - Select the database you want to delete from the left sidebar.
- Click
Operationsat the top. - Under
Remove database, clickDrop the database (DROP). - Click OK to confirm deletion.
- If a cPanel user owned the database, delete its entry in
Manage My Databases.
Important: Manually deleting a database without removing its entry in cPanel corrupts the database map and causes backup errors.
2. Enable the Slow Query Log in MySQL or MariaDB
To enable the Slow Query Log, follow these steps:
- Log in via SSH as
root. - Edit the
my.cnffile and add the following under[mysqld]:
slow_query_log = 1
slow-query_log_file = /var/log/mysql-slow.log
long_query_time = 2Variable names differ in older MySQL and newer MariaDB versions.
Create the log file
touch /var/log/mysql-slow.log
chown mysql:mysql /var/log/mysql-slow.logRestart MySQL
/usr/local/cpanel/scripts/restartsrv_mysqlAnalyze slow queries
mysqldumpslow -a /var/log/mysql-slow.log3. Resolve Password Authentication Failed Errors in PostgreSQL
If you receive a Password authentication failed error, follow these steps:
Check the pgpass file
The /root/.pgpass file must contain:
::*:postgres:PASSWORDEdit pg_hba.conf
- Stop Tailwatch:
touch /etc/tailwatchddisable
killall tailwatchd- Edit
pg_hba.confand changemd5totrust. - Restart PostgreSQL:
/usr/local/cpanel/scripts/restartsrv_postgresqlChange the PostgreSQL password
postgres=# alter user postgres with encrypted password 'new_pass';
postgres=# \q- Revert
trustback tomd5. - Re-enable Tailwatch:
rm /etc/tailwatchddisable
/usr/local/cpanel/scripts/restartsrv_tailwatchd4. Restore a User’s Database Access with restoregrants
Use the restoregrants script to restore database privileges:
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type --dbuser=$dbuser
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type --allVariables:
$cpuser: cPanel username$dbuser: database user$type: mysql or pg
If restoregrants fails
Reset the cPanel account password to rebuild grants.
5. Install or Update PostgreSQL
Before installing or upgrading PostgreSQL, back up your databases:
pg_dumpall -U postgres > db.outStop PostgreSQL and move the data directory
systemctl stop postgresql.service
mv /var/lib/pgsql /var/lib/directory_file_name6. Install or Upgrade PostgreSQL
/usr/local/cpanel/scripts/installpostgresThen configure PostgreSQL in WHM under Configure PostgreSQL.
Import databases
psql -U postgres dbname < dumpfile.sql7. Restore a Previous PostgreSQL Version
systemctl stop postgresql.service
mv /var/lib/pgsql /var/lib/directory_file_name
mv /var/lib/pgsql.old /var/lib/pgsql
systemctl restart postgresql.serviceFor more details, visit the PostgreSQL website.
Written & researched by Dr. Shahin Siami