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
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:
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
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.)
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
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:
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.
Log in to MySQL as the targeted user:
# mysql -u testuser -p
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
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.