//Web Panel

Configure MySQL Governor on CloudLinux to Stop Heavy DB Users

Learn how to install, configure, and monitor MySQL Governor on CloudLinux to limit resource usage per account and keep shared hosting stable.

5 min read
Configure MySQL Governor on CloudLinux to Stop Heavy DB Users

Running a shared‑hosting environment on CloudLinux gives you powerful tools to keep abusive users from affecting the whole server. A frequent issue is a single account that runs heavy MySQL queries, consuming CPU, RAM and I/O and degrading performance for everyone else. The MySQL Governor module in CloudLinux detects and throttles these “database‑hogging” accounts before they cause real damage.

What Is MySQL Governor and Why Use It?

MySQL Governor is a lightweight, kernel‑level extension that monitors MySQL connections per user and enforces limits on:

  • Maximum concurrent connections
  • Query execution time
  • Memory usage per connection

When a user exceeds any of these thresholds, Governor automatically reduces the allowed resources for that user, effectively “throttling” the account without manual intervention. This helps you maintain stable performance across all accounts on a shared server.

Prerequisites

Before you begin, ensure you have:

  • A CloudLinux server with root access.
  • MySQL or MariaDB installed (Governor works with both).
  • LVE Manager installed – required for Governor to apply limits.

The steps below are written for CloudLinux 8, which uses dnf as the package manager. If you are on CloudLinux 7, replace dnf with yum.

Installing the MySQL Governor Package

Enable the CloudLinux repository and install the Governor module:

# dnf install -y cl-governor-mysql

What the command does

  • dnf install -y – downloads and installs the package without prompting.
  • cl-governor-mysql – provides the MySQL Governor kernel module and its configuration utilities.

After installation the module loads automatically. Verify it with:

# lsmod | grep governor_mysql
governor_mysql          16384  0

Configuring Global Governor Settings

The main configuration file is /etc/governor/mysql.cfg. Edit it with your preferred editor:

# vi /etc/governor/mysql.cfg

Key global directives:

  • max_connections – total MySQL connections allowed on the server.
  • default_conn_limit – per‑user connection limit applied when no specific rule exists.
  • query_time_limit – maximum query execution time (seconds) before Governor throttles it.

Example configuration:

max_connections=500
default_conn_limit=20
query_time_limit=10

Save the file and restart the Governor service so the changes take effect:

# systemctl restart governor-mysql

Creating Per‑User Limits

To throttle a specific account, create a rule that ties the MySQL user to an LVE (Lightweight Virtual Environment) ID. Most shared‑hosting panels (cPanel, Plesk, DirectAdmin) already map each account to an LVE ID, but you can also list them manually:

# lvectl list

The output shows LVEs with their IDs and owners. Note the ID of the account you want to limit.

Step‑by‑step rule creation

  1. Open (or create) the per‑user configuration file. Each LVE has its own file under /etc/governor/mysql.d/:
    # vi /etc/governor/mysql.d/12345.cfg
    
    (Replace 12345 with the actual LVE ID.)
  2. Add the limits you wish to enforce. For example, to cap the account at 5 concurrent connections and kill queries longer than 8 seconds:
    conn_limit=5
    query_time_limit=8
    
  3. Save the file and reload Governor:
    # systemctl reload governor-mysql
    

To block an account completely, set conn_limit=0. Existing connections will finish, but no new connections will be allowed.

Monitoring and Fine‑Tuning

Governor includes tools to view current usage and the impact of your limits.

Viewing Live Statistics

# governor-mysql-stats

The command prints a table with columns such as:

  • LVE ID
  • Current connections
  • Queries throttled
  • Memory used per connection

Identify accounts that frequently hit limits and adjust their per‑user rules accordingly.

Logging

All throttling events are logged to /var/log/governor/mysql.log. Watch the log in real time with:

# tail -f /var/log/governor/mysql.log

Typical entries look like:

[2026-10-02 14:23:11] LVE 12345: connection limit exceeded (20/5)
[2026-10-02 14:27:45] LVE 67890: query time limit exceeded (12s)

Adjusting Thresholds

If legitimate traffic is being throttled, soften the limits—for example, increase query_time_limit from 8 to 12 seconds or raise conn_limit for that LVE.

Integrating with cPanel/WHM (Optional)

Most CloudLinux users run cPanel/WHM, which includes a UI for MySQL Governor under Home » CloudLinux » MySQL Governor. The interface mirrors the command‑line steps described above:

  • Select an account.
  • Set “Maximum Connections” and “Query Time Limit”.
  • Save changes; the system reloads Governor automatically.

The UI simplifies management for administrators who prefer a graphical approach, while the command line remains essential for scripting or bulk updates.

Testing Your Configuration

After applying limits, verify that they work as expected.

  1. Log in to MySQL as the targeted user:
    # mysql -u testuser -p
    
  2. Open multiple terminal windows and start simultaneous connections until you exceed conn_limit. Extra connections should be rejected with:
    ERROR 1040 (HY000): Too many connections
    
  3. Run a deliberately long query, e.g. SELECT SLEEP(15);. Governor should terminate it after the configured query_time_limit, and the client will receive:
    ERROR 1317 (HY000): Query execution was interrupted
    

If the observed behavior matches the limits you set, the configuration is successful.

Conclusion

MySQL Governor provides a low‑overhead, effective way to protect a CloudLinux shared‑hosting server from accounts that consume disproportionate database resources. By installing cl-governor-mysql, defining sensible global defaults, and adding per‑user rules for problematic accounts, you can automatically throttle or block heavy queries without manual intervention. Regular monitoring with governor-mysql-stats and log review helps you fine‑tune limits and keep the hosting environment stable for all users.

mysql governorcloudlinuxshared hostingmysql limitsserver monitoringlvemysql governor configgovernor-mysql stats

Try it on your own server

Follow along on a Cloud VPS with full root access, or read the step-by-step knowledge base guides.