No announcement yet.

max_user_connections errors

  • Filter
  • Time
  • Show
Clear All
new posts

  • max_user_connections errors

    max_user_connections errors

    max_user_connections error is related to MySQL. Server gives 'Too Many Connections' error whenever there is no room in the connection pool for the new connection objects. Hence, each company limit this connection on their server specification.

    Error :

    Warning: mysql_connect(): User cpaneluser_databaseuser has already more than 'max_user_connections' active connections in /home/username/public_html/script.php on line xxxx

    User cpaneluser_xxx has already more than 'max_user_connections' active connections

    Correction :

    The settings are located in the /etc/my.cnf

    We can set or manage the limit from here editing file my.cnf

    max_user_connections = 20

    you can change it

    max_user_connections =30
    On shared server we implies a concurrent connections per mysql user limit on script to prevent heavy mysql load on the server and to hunt down scripts that use unnecessary mysql connections due to bad coding practices.


    These errors can be prevented by some coding tweaks into your script.

    [i] Use of mysql_connect() for connections to mysql dbs in your code. The advantage is :

    "The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close()."

    [ii] Use function mysql_close() explicitly. Although mysql_connect() closes the connections, use of mysql_close() in conjunction with it would make sure that the connection is totally closed.

    [iii] Don't use mysql_pconnect(). The mysql_pconnect is disabled on server.

    "The connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect)"

    You can also refer :

    PHP: mysql_connect - Manual
    PHP: mysql_close - Manual
    PHP: mysql_pconnect - Manual