MAX_CONNECTIONS_PER_HOUR | mysql.user max_connections, Consternation.
Option (and column) max_connections in the user grants stored in table user is used to represent the maximum of user connections per hour (conforming to the documentation).
In order to fulfill the data in this column I use SQL syntax:
mysql> GRANT USAGE ON *.* TO 'test'@'localhost' WITH MAX_CONNECTIONS_PER_HOUR 5;
Query OK, 0 rows affected (0.01 sec);
mysql> flush user_resources;
Query OK, 0 rows affected (0.00 sec)
Next, I open session with command line:
# Session 1
mysql -utest -p;
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1951229
Server version: 5.1.43-log Source distribution
Then, I execute php script wich opens 10 sessions at once:
As a result I see 0123456789. Successfuly I opened 10 connections to MySQL.
I reexecute my php script. Failure, each time I receive an error:
User 'test' has exceeded the 'max_connections_per_hour' resource (current value: 5);
I go to my Session 1 and execute a query:
mysql> select 1 from dual;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
I execute my php script and... all connections are successful! That means that any SELECT made by the user who was limited (obviously logged before limit) works like FLUSH RESOURCES;
Tested on WINDOWS 5.1.51-community and CENTOS 5.1.43-log.
My interpretation of MAX_CONNECTIONS_PER_HOUR (mysql.user max_connections) is as follows:
Block access for a hour to the user who executed more connections at once than MAX_CONNECTIONS_PER_HOUR. The question is, it is "The number of times an account can connect to the server per hour"?
No comments yet.