I'm using MySQL Community Server 5.5 with PHP 5.3.3 on a Windows Server 2008 platform. I have set up per user resources limits, particularly a limit related to the queries run by a DB user within one hour. I have read this document and it is very interesting but always it doesn't work for me.
http://dev.mysql.com/doc/refman/5.5/en/user-resources.html
When I run a query via mysql command line tool (mysql.exe) the limit works properly and if the queries limit per hour was 7, after 7 queries within one hour I receive the error:
ERROR 1226 (42000): User 'user' has exceeded the 'max_questions' resource (current value: 7)
This above is the wanted behavior.
When I run a query via PHP (The user I have used to connect to the DB is the same above), the queries limit doesn't work: the same user via php can run all the queries it wants and without any limit. And if I come back on the mysql command line above the counter seems to be reset (even if the hour hasn't elapsed) : I can run 7 queries within an hour too. I think this isn't the wanted behaviour. It seems that PHP resets the counter and doesn't trigger the queries limit.
PS: The 'user' owns only SELECT,INSERT,UPDATE,DELETE privileges and in the PHP code there isn't any SQL code as FLUSH USER_RESOURCES that the user 'user' couldn't have run (because RELOAD privilege isn't assigned to the user)
Thanks in advance
I think you are doing little mistake,
Please check for the host in your mysql_connect function into php. if your host is IP address then you need to assign the resource limit to username@yourip or username@%
If you are running through the command line then you are login from username@localhost and you have assign the limit to the same user.
Please try my above tricks and let me know if you are having problem still ?
Happy coding....