How to Configure MySQL in WHM: Database Server Settings, Security, and Optimization

Overview

WHM (Web Host Manager) provides a centralized interface for managing your server’s MySQL or MariaDB database server — including version selection, configuration tuning, user management, and security hardening. Whether you’re setting up a fresh VPS or tightening security on an existing server, knowing where these controls live and what they actually do saves a lot of time.

Most hosting admins encounter WHM MySQL settings when they’re either spinning up a new server, troubleshooting slow query performance, or responding to a security audit. The default configuration that ships with cPanel/WHM is functional, but it’s not hardened and it’s not optimized for production workloads. You’ll need to make deliberate choices here.

This article covers the essential WHM MySQL configuration steps, including version management, my.cnf tuning, root account security, and the gotchas that aren’t obvious from the UI alone. If you’re running reseller hosting and managing databases on behalf of clients, these settings affect every account on your server — so it’s worth getting them right from the start.

Prerequisites

  • Root access to WHM (typically via https://yourserver.com:2087)
  • A cPanel/WHM installation (version 110 or later recommended; steps are consistent across recent releases as of 2026)
  • SSH access to the server for command-line steps
  • Basic familiarity with what a database server does (you don’t need to be a DBA)
  • A backup of any existing databases before making configuration changes — especially before upgrading MySQL/MariaDB versions

Step-by-Step Instructions

Step 1: Access MySQL/MariaDB Manager in WHM

Log into WHM as root. In the left-hand search bar, type MySQL. You’ll see several relevant options — the one you want first is MySQL/MariaDB Manager under the SQL Services section.

This panel shows your currently installed database engine and version, and lets you switch between MySQL and MariaDB releases. On most cPanel servers today, MariaDB 10.6 or 10.11 is the default. MySQL 8.0 is also supported if you need it for a specific application.

📝 Note: MariaDB and MySQL are largely compatible but not identical. Some MySQL 8.0 features (like specific JSON functions or certain authentication plugins) behave differently under MariaDB. If your application explicitly requires MySQL 8.0, select it here — otherwise, MariaDB 10.6+ is a solid default.

Step 2: Install or Upgrade Your Database Version

In the MySQL/MariaDB Manager, you’ll see a list of available versions. To install or upgrade:

  1. Select your target version from the dropdown.
  2. Click Install (or Upgrade if you’re moving to a newer release).
  3. WHM will run the upgrade process, which includes a mysql_upgrade equivalent automatically. This can take several minutes.

⚠ Warning: Upgrading from MariaDB 10.5 to 10.11 (or MySQL 5.7 to 8.0) is not always reversible cleanly. Take a full server backup — or at minimum a mysqldump of all databases — before proceeding.

Step 3: Edit the MySQL Configuration File (my.cnf)

WHM provides a GUI editor for /etc/my.cnf under SQL Services > MySQL Configuration Editor. This is where you tune performance-related settings.

For a typical VPS with 4GB RAM running mixed WordPress and application workloads, here’s a reasonable baseline for the [mysqld] section:

[mysqld]
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
max_connections = 150
query_cache_type = 0
query_cache_size = 0
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/slow.log
long_query_time = 2
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

A few things worth explaining here:

  • innodb_buffer_pool_size: Set this to roughly 50-70% of available RAM on a dedicated database server. On a shared VPS, be conservative — over-allocating here starves other processes.
  • query_cache_type = 0: The query cache is disabled in MySQL 8.0 and causes contention in MariaDB under concurrent load. Disable it explicitly — many default configs still have it enabled.
  • slow_query_log: Turn this on. You’ll thank yourself later when a poorly indexed query starts hammering your server at 2am.
  • utf8mb4: Use this instead of utf8. MySQL’s utf8 is actually a 3-byte subset and doesn’t handle emoji or certain Unicode characters correctly. utf8mb4 is the real thing.

After saving changes in the GUI editor, restart MySQL via WHM under Restart Services > SQL Server (MySQL) or via SSH:

systemctl restart mysql

Step 4: Secure the MySQL Root Account

This is the step most people skip, and it’s the one that matters most for security.

On many Linux distributions (especially those using systemd), MySQL/MariaDB configures root to authenticate via the unix_socket or auth_socket plugin rather than a password. This means mysql_secure_installation can fail or behave unexpectedly when it tries to set a root password — it’ll report success but the password won’t actually work for remote or application-level connections.

Here’s the reliable approach. First, connect as root via socket auth:

sudo mysql

Then, inside the MySQL shell, switch root to use native password authentication and set a strong password. Replace YourStrongPasswordHere with something real — and do not leave this placeholder in production:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourStrongPasswordHere';
FLUSH PRIVILEGES;
EXIT;

📝 Note: On MariaDB 10.4+, the equivalent plugin name is mysql_native_password — same as above. On MariaDB 11.x, check the plugin name with SELECT user, plugin FROM mysql.user; first, as this is evolving.

Now run the hardening script:

mysql_secure_installation

Answer the prompts: keep the root password you just set, remove anonymous users, disallow remote root login, remove the test database, and reload privilege tables. All of these should be Yes on a production server.

Step 5: Manage MySQL Users and Databases via WHM

For day-to-day database management, WHM’s SQL Services section includes:

  • MySQL Root Password: Updates the root password and syncs it with cPanel’s stored credentials.
  • Additional MySQL Access Hosts: Controls which IP addresses can connect to MySQL remotely. Add specific IPs here if your application servers need external database access. Don’t open this to 0.0.0.0 unless you have a very specific, firewall-protected reason.
  • Manage MySQL Profiles: Relevant if you’re connecting WHM to a remote MySQL server — common on larger dedicated server setups where the database tier is separated from the web tier.

Individual cPanel users manage their own databases and users through their cPanel interface, under Databases > MySQL Databases. As a WHM admin, you can view and manage all databases server-wide via phpMyAdmin under SQL Services.

Common Issues and Troubleshooting

MySQL Won’t Start After Editing my.cnf

Usually a syntax error in the config file. Check the error log:

journalctl -xeu mysql --no-pager | tail -50

Or check MariaDB’s log directly:

cat /var/log/mariadb/mariadb.log

Look for lines starting with [ERROR]. Nine times out of ten, it’s a typo, a missing equals sign, or a value that exceeds available memory. Fix the value in /etc/my.cnf and restart.

mysql_secure_installation Fails with “Access Denied”

This is annoyingly common and the official docs aren’t great on it. It means root is using socket authentication (see Step 4 above). The fix is to switch root to mysql_native_password first using sudo mysql, then rerun the hardening script. Follow the exact sequence in Step 4.

Too Many Connections Error

Applications return ERROR 1040: Too many connections. This means you’ve hit the max_connections limit in my.cnf. You can check current usage without restarting:

SHOW STATUS LIKE 'Max_used_connections';
SHOW VARIABLES LIKE 'max_connections';

If Max_used_connections is close to or equal to max_connections, increase the limit in my.cnf. But also check whether a connection leak in your application is the real cause — a WordPress site with a misconfigured persistent connection plugin can exhaust connections fast.

WHM Shows Wrong MySQL Version After Upgrade

The WHM interface sometimes caches the version display. Try a hard refresh, then check the actual running version via SSH:

mysql --version

If the binary version doesn’t match what you selected in WHM’s MySQL Manager, the upgrade may have failed silently. Check /usr/local/cpanel/logs/mysql_upgrade_mysql.log for details.

Remote MySQL Connection Refused Despite Adding Access Host

Adding an access host in WHM is only half the job. You also need to make sure the MySQL bind address isn’t set to 127.0.0.1 in /etc/my.cnf:

grep bind-address /etc/my.cnf

If it’s set to 127.0.0.1, change it to 0.0.0.0 (or a specific interface IP) and restart MySQL. Then verify your server firewall (CSF or iptables) allows inbound connections on port 3306 from the remote IP.

Related Resources

If you’re managing databases across multiple client accounts, Host & Tech’s Reseller Hosting plans include WHM access with full MySQL management capabilities, so you can configure database settings server-wide while your clients manage individual databases through their own cPanel interfaces.

Frequently Asked Questions

How do I reset the MySQL root password in WHM?

Go to WHM > SQL Services > MySQL Root Password and enter a new password. WHM updates the password and syncs it with its own stored credentials automatically. If MySQL won’t accept the new password through WHM, you may need to reset it via SSH using sudo mysql and an ALTER USER statement as described in Step 4 of this guide.

Should I use MySQL or MariaDB on my cPanel server?

For most hosting scenarios — WordPress, Joomla, Magento, general PHP apps — MariaDB 10.6 or 10.11 is the right choice. It’s actively maintained, performs well under concurrent load, and is fully compatible with standard MySQL queries. Only choose MySQL 8.0 if a specific application explicitly requires it, since some MySQL 8.0 authentication or JSON behaviours differ from MariaDB.

Can I connect to MySQL remotely on my WHM server?

Yes, but you need to do two things: add the remote IP under WHM > SQL Services > Additional MySQL Access Hosts, and make sure MySQL’s bind address in /etc/my.cnf is not restricted to 127.0.0.1. You’ll also need port 3306 open in your server firewall for that specific IP. Leaving port 3306 open to all IPs is a security risk — always whitelist specific addresses.

What's the difference between MySQL Manager and MySQL Configuration Editor in WHM?

MySQL Manager handles version selection and installation — it’s where you switch between MariaDB and MySQL releases. MySQL Configuration Editor is a GUI for editing /etc/my.cnf, the file that controls performance tuning, logging, and connection limits. They’re separate tools under the same SQL Services section in WHM.

How do I find slow queries on my database server?

Enable the slow query log in /etc/my.cnf by setting slow_query_log = 1 and long_query_time = 2 (logs queries taking over 2 seconds). The log file path is set with slow_query_log_file. Once enabled, you can analyse the log with mysqldumpslow or the pt-query-digest tool from Percona Toolkit to identify problematic queries.

SHARE THIS ARTICLE

Need help with your hosting?

Host & Tech provides 24/7 support for all VPS, dedicated, and shared hosting customers.

Scroll to Top