MYSQLi error: User already has more than 'max_user_connections' active connections

前端 未结 6 1473
猫巷女王i
猫巷女王i 2020-11-28 13:34

I have this error below on a site I am running. I don\'t understand why is that as it works fine on my localhost. Is it something to do with the host? I am on an Unix server

相关标签:
6条回答
  • 2020-11-28 14:16

    For this on Godaddy shared hosting, you cant change the MAX_USER_CONNECTION value. To find it, click Server<>, then click Variables in the menu-bar. Mine is set to 200.

    0 讨论(0)
  • 2020-11-28 14:17

    If you get this max_user_connections message first optimize your database table.

    How to optimize database table and query:

    1. Index your table field in mysql
    2. In select query remove `*` and write which you need field
    3. Closed mysql_connection
    0 讨论(0)
  • 2020-11-28 14:19

    to check numbers of connection login to mysql using command line and run this command

    SHOW VARIABLES LIKE 'max_user_connections
    

    STEP #1 : Look setting in /etc/my.cnf

    max_user_connections = <set number that you want>
    

    max_user_connections =

    you can set from mysql command line too

    SET GLOBAL max_user_connections = 0;
    

    restart your apache server

    0 讨论(0)
  • 2020-11-28 14:20

    Check the MAX USER_CONNECTIONS setting on your MySQL server for the user. In PHPMyAdmin go to the server page (Click on the Server:<>) and in the sub-menu click on priviledges. Edit the user dbo343879423 and the MAX USER_CONNECTIONS will be on the right side. By default I believe it is set to 0 (unlimited), yours maybe restricted depending on who setup the server.

    I'm not sure how your Database class is being used but if you are instantiating the class multiple times consider creating a private static variable Database in the database class and creating a public static method getDatabase() which instantiates the database connection if it is null and returns the instance.

    0 讨论(0)
  • 2020-11-28 14:22

    For what its worth I wanted to include a situation I ran into where I received this message due to an incorrect placeholder:

          $sql_str = 'SELECT prod_id FROM ' . $this->table_name["product"] . ' WHERE prod_sku =:p_sku';
        $arr[':prod_sku'] = $s_sku;
    

    In addition I was doing a large number of queries. I suspect that the error compounded with the large number of queries caused this issue. When I fixed the query the connections issue when away.

    0 讨论(0)
  • 2020-11-28 14:31

    Probably the problem is that you have only a handful connections allowed and when your class tries to get a new connection you have this error.

    This is not a programming problem, just quantity of resources available. And any other script that uses this class are subject to have the error.

    You have to configure more connections on mysql config file on the server. If you don't have this access, ask the support to do it or change for a hosting company with more connections allowed!

    Other option is to implement a Singleton pattern on this class, so it reuses same pool of connections, and don't explode the limit.

    0 讨论(0)
提交回复
热议问题