How to Delete a MySQL Database and Manage Database Issues in cPanel & WHM

This article explains how to manually delete a MySQL database, enable the Slow Query Log in MySQL or MariaDB, resolve PostgreSQL password authentication errors, restore a user’s database access using restoregrants, and install or update PostgreSQL on a cPanel & WHM server.

MySQL DatabaseDelete PostgreSQLError Fix restoregrants cPanel

~3 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:


  1. Log in to WHM as the root user.
  2. Navigate to SQL Services and click phpMyAdmin.
  3. Select the database you want to delete from the left sidebar.
  4. Click Operations at the top.
  5. Under Remove database, click Drop the database (DROP).
  6. Click OK to confirm deletion.
  7. 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:


  1. Log in via SSH as root.
  2. Edit the my.cnf file and add the following under [mysqld]:

slow_query_log = 1
slow-query_log_file = /var/log/mysql-slow.log
long_query_time = 2

Variable 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.log

Restart MySQL


/usr/local/cpanel/scripts/restartsrv_mysql

Analyze slow queries


mysqldumpslow -a /var/log/mysql-slow.log

3. 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:PASSWORD

Edit pg_hba.conf


  1. Stop Tailwatch:

touch /etc/tailwatchddisable
killall tailwatchd

  1. Edit pg_hba.conf and change md5 to trust.
  2. Restart PostgreSQL:

/usr/local/cpanel/scripts/restartsrv_postgresql

Change the PostgreSQL password


postgres=# alter user postgres with encrypted password 'new_pass';
postgres=# \q

  1. Revert trust back to md5.
  2. Re-enable Tailwatch:

rm /etc/tailwatchddisable
/usr/local/cpanel/scripts/restartsrv_tailwatchd

4. 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 --all

Variables:


  • $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.out

Stop PostgreSQL and move the data directory


systemctl stop postgresql.service
mv /var/lib/pgsql /var/lib/directory_file_name

6. Install or Upgrade PostgreSQL


/usr/local/cpanel/scripts/installpostgres

Then configure PostgreSQL in WHM under Configure PostgreSQL.


Import databases


psql -U postgres dbname < dumpfile.sql

7. 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.service

For more details, visit the PostgreSQL website.


Written & researched by Dr. Shahin Siami

Related Articles

How to Restore Your cPanel Account: A Complete Guide for New System Administrators

This guide explains how new system administrators can restore a cPanel account using WHM, transfer accounts and configurations between servers, and enable diagnostic logging for transfer and restore operations. It covers essential concepts such as WHM vs. cPanel, root access, backup handling, SFTP uploads, transfer methods, and advanced debugging tools.

Continue

آموزش کامل انتقال تمام اکانت‌های cPanel از یک سرور به سرور دیگر

این مقاله نحوه انتقال همه اکانت‌های cPanel، تنظیمات سرویس‌ها، گواهی‌های SSL و IP اصلی سرور را از یک سرور قدیمی (Source) به یک سرور جدید (Target) توضیح می‌دهد. شامل نصب سرور جدید، انتقال تنظیمات، انتقال اکانت‌ها، تغییر IP، تنظیم DNS و نصب مجدد SSL است.

Continue

How to Migrate a WordPress® Installation to a cPanel & WHM Server

This guide explains how to migrate a WordPress installation from a macOS-hosted environment to a cPanel & WHM server. It covers exporting the database, uploading WordPress files, creating and importing a MySQL database, updating URLs, configuring wp-config.php, fixing broken links, and finalizing the migration.

Continue

How to Manually Transfer an Account Between Servers in cPanel & WHM

This article explains how to manually transfer a cPanel account between servers when the account is too large for WHM’s automated transfer tools. It covers creating temporary directories, compressing public_html and log files, securely transferring data with SCP, and restoring the files on the destination server.

Continue

How to Manually Migrate Horde Calendars and Contacts to Roundcube in cPanel & WHM

This article explains how to manually migrate Horde calendars and contacts to Roundcube in cPanel & WHM version 108 through 118. It covers exporting Horde data, placing it in the correct directories, and importing it into Roundcube using built‑in plugins or manual import tools.

Continue

How to Manually Migrate Accounts to cPanel & WHM from Unsupported Control Panels

This article explains how experienced system administrators can manually migrate accounts from unsupported third‑party control panels to cPanel & WHM. It covers pre‑migration steps, installation requirements, file and directory transfers, database restoration, SSL migration, and post‑migration tasks.

Continue