Skip to content

Setting per-account database quotas on cPanel — what the UI controls, what MySQL ignores

cPanel's reseller plan database quota counts database objects, not disk space. The disk-quota fight happens elsewhere — and ignoring this is how one customer fills /var/lib/mysql.

A cPanel reseller plan has a “Max Databases” field. An admin sets it to 10 and moves on, assuming this caps each account’s database footprint. Three weeks later, one customer with a single database has 80 GB of data in wp_postmeta, /var/lib/mysql is at 95%, and the quota was never the right knob. The “database quota” in cPanel counts database objects (how many CREATE DATABASE statements an account can issue), not disk space. Disk space is enforced through the account’s home directory quota — and /var/lib/mysql is not in the home directory.

What’s happening

cPanel’s account quota system tracks files under /home/<user> against the account’s allowed limit. MySQL data lives under /var/lib/mysql/<dbname>/ — outside the home directory — so MySQL writes are invisible to the account quota system. A customer running wp_options autoload with hundreds of MB of cached transients can fill the disk shared with other accounts and never hit their own quota.

cPanel has three relevant settings:

  • Max Databases (plan): how many databases an account can create. Counts CREATE DATABASE.
  • Max Database Users: how many users the account can create.
  • Disk Quota (account): limits /home/<user> only. Excludes /var/lib/mysql.

For disk-quota enforcement on databases, cPanel offers no native solution. The options are: CloudLinux + MySQL Governor (separate article) which can throttle but doesn’t strictly cap disk; per-account filesystem quotas via XFS project quotas; or --databases checks in a nightly cron that emails when an account crosses a threshold.

How to verify

whmapi1 listacctsfeatures user=acmecorp | grep -i max
whmapi1 list_dbs user=acmecorp
du -sh /var/lib/mysql/acmecorp_*
mysql -e "SELECT TABLE_SCHEMA, SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 AS mb FROM information_schema.TABLES WHERE TABLE_SCHEMA LIKE 'acmecorp\\_%' GROUP BY TABLE_SCHEMA"
quota -u acmecorp
df -h /var/lib/mysql

The first command shows the plan limits. The du is what the account is actually consuming on the MySQL volume. The quota is what cPanel thinks the account is using — these two numbers will not match because home and MySQL are separate.

The fix

  1. Set realistic Max Databases on plans. Most accounts need 1–5 databases. A plan that allows 200 databases per account invites abuse — every WordPress install ends up creating a database, and there are accounts with 50 abandoned WordPress installs eating disk.
  2. Add a nightly per-account database size report. A simple cron:
    #!/bin/bash
    mysql -N -e "SELECT TABLE_SCHEMA, ROUND(SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024) AS mb FROM information_schema.TABLES GROUP BY TABLE_SCHEMA ORDER BY mb DESC" | while read schema mb; do
      user=$(echo "$schema" | cut -d_ -f1)
      if [ "$mb" -gt 5000 ]; then
        echo "$user: $schema = $mb MB"
      fi
    done > /root/db-size-report.txt
    mail -s "DB size report" admin@example.com < /root/db-size-report.txt
    Sends a daily list of databases over 5 GB. Catches the runaway before it fills disk.
  3. For strict per-account disk quotas on MySQL, use XFS project quotas on /var/lib/mysql. Mount with pquota, assign each cPanel user’s MySQL directories to a project ID, set the quota. This requires XFS and root-level setup but is the only way to hard-cap database disk usage per account without an external tool.
  4. For CloudLinux hosts, MySQL Governor (separate article) throttles IO and CPU per account but does not cap disk. The two tools complement each other.
  5. Educate customers on cleanup. WordPress wp_options autoload, expired transients, wp_postmeta orphans, abandoned plugins’ tables — these accumulate. A monthly wp-cli cleanup or a database maintenance task as part of environment management keeps growth predictable.

For multi-tenant cPanel hosts where one customer’s database keeps surprising the others, Stack Harbor’s cPanel/WHM management team configures XFS project quotas on the MySQL volume and reports per-account usage on a scheduled cadence so plan upgrades happen before disk pressure does.