Limit the use of server resources by setting the global MAX_USER_CONNECTIONS variable to a non-zero value. This limits the number of simultaneous connections by any one account but does not limit what a client can do when connected. To set resource limits for an account, use the GRANT statement with a WITH clause that names each resource to be limited. The default value for each limit is zero, indicating no limit. For example, to set limits for user Francis to access the customer database, issue the following statement:
mysql> GRANT ALL ON customer.* TO 'francis'@'localhost' -> WITH MAX_QUERIES_PER_HOUR 20 -> MAX_UPDATES_PER_HOUR 10 -> MAX_CONNECTIONS_PER_HOUR 5 -> MAX_USER_CONNECTIONS 2;
Limit the following server resources for individual accounts:
- MAX_QUERIES_PER_HOUR: The number of queries that an account can issue per hour
- MAX_UPDATES_PER_HOUR: The number of updates that an account can issue per hour
- MAX_CONNECTIONS_PER_HOUR: The number of times an account can connect to the server per hour
- MAX_USER_CONNECTIONS: The number of simultaneous connections allowed.
Provide resource limits in the WITH clause in any order. Set the MAX_USER_CONNECTIONS limit to 0 to set it to the global default, indicating that the maximum number of simultaneous connections allowed for this account is the global value of the max_user_connections system variable.
To reset an existing limit for any of the per-hour resources to the default of “no limit,” specify a value of 0, as in this example:
mysql> GRANT USAGE ON *.* TO 'quinn'@'localhost' -> WITH MAX_CONNECTIONS_PER_HOUR 0;