3

I'm getting an error while running php script for Wordpress site on same domain:

Could not connect: User 'abc' has exceeded the 'max_connections_per_hour' resource (current value: 10)

What should be the limit for MySql database? Now should I connect to the database?

dcaswell
  • 3,137
  • 2
  • 26
  • 25
user2216267
  • 491
  • 3
  • 8
  • 21

1 Answers1

6

You exceed limit for mysql, take a look at mysql doc, and you can see this :

GRANT ALL ON customer.* TO 'francis'@'localhost'
IDENTIFIED BY 'frank'
WITH MAX_QUERIES_PER_HOUR 20
     MAX_UPDATES_PER_HOUR 10
     MAX_CONNECTIONS_PER_HOUR 5;

You just have to increase MAX_CONNECTIONS_PER_HOUR or to remove limit, just use this :

GRANT USAGE ON *.* TO 'francis'@'localhost' WITH MAX_CONNECTIONS_PER_HOUR 0;

To allow persistent connection on WordPress, take a look at this article (I have not tested it myself) : http://www.mydigitallife.info/using-php-mysql-persistent-connections-to-run-wordpress-blog/

Dharman
  • 30,962
  • 25
  • 85
  • 135
Supernini
  • 591
  • 5
  • 8
  • what exactly it will do, will change limit to unlimited ? can it be dangerous ? – user2216267 Sep 26 '13 at 17:25
  • That is, assuming his web host hasn't set a limit, which he has no privilege to override. – Mark Sep 26 '13 at 17:27
  • ideally what should be the limit for MAX_CONNECTIONS_PER_HOUR ? – user2216267 Sep 26 '13 at 17:33
  • 2
    Removing limit can be dangerous ! that true ! The best thing should be to add persistante connexion to prevent re-connexion – Supernini Sep 26 '13 at 17:34
  • i have a website which gets around 90,000+ visitors...but its not running because of this for months....what should i change the MAX_CONNECTIONS_PER_HOUR value to ? any solution ? – user2216267 Sep 26 '13 at 17:39
  • 1
    I edited my answer, follow the link and change the config file to allow persistent connexion – Supernini Sep 26 '13 at 17:41
  • nice article, but it is giving the same error after changing to mysql_pconnect, im using a simple php script to check connection, but it is giving the same error, maybe anything at phpmyadmin side required ? should is change limit to 5000 ? or anything related to emptying cache ? database size ? – user2216267 Sep 26 '13 at 18:17
  • 1
    To check where the problem come from, start by setting max_connections_per_hour to 0 (unlimited). Your website will work fine, then try to play with mysql_pconnect – Supernini Sep 27 '13 at 16:05
  • If you have that many users in your website opening requests I would advice you to look on how to implement a connection pool to your application. That way connections will be reused by the application and requests would be queued to use a connection whenever it gets released back to the pool – Jorge Campos Jan 13 '21 at 17:34