SQLSTATE[HY000] [1040] Too many connections

前端 未结 3 726
萌比男神i
萌比男神i 2020-12-21 08:17

Sometimes when I open my error log file I see this this error

[14-Jun-2014 19:09:55 UTC] PHP Fatal error: Uncaught exception \'PDOException\' with

3条回答
  •  天涯浪人
    2020-12-21 08:34

    This is a limit of database's configuration. If you have permission to edit the configuration file of your database service, you can change max_connections value.

    Take a look: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html

    You can try running this SQL query (take care about this value!)

    SET GLOBAL max_connections = 512;
    

    and this to get current value of all variables:

    SHOW VARIABLES;
    

    or (for specific variable):

    SHOW GLOBAL VARIABLES LIKE '%max_connections%'
    

    By the way, try to set PDO object to null when you don't need it. This will close connection to your database and PHP does not wait for script to finish to close active connections. (Oh, you did it, sorry, I will not edit it to delete. Get it as a note)

提交回复
热议问题