php, mysql - Too many connections to database error

前端 未结 6 1557
南方客
南方客 2020-12-03 10:40

Good day to all. I have an odd error. I have created a chat that works like this:

  • questions/answers are inserted into a db
  • every 2 seconds an ajax re
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 11:45

    If you need to increase MySQL Connections without MySQL restart do like below, also if you don't know configuration file, below use the mysqlworkbench or phpmyadmin or command prompt to run below queries.

    mysql> show variables like 'max_connections';
    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 151   |
    +-----------------+-------+
    1 row in set (0.00 sec)
    
    mysql> SET GLOBAL max_connections = 250;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show variables like 'max_connections';
    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 250   |
    +-----------------+-------+
    1 row in set (0.00 sec)
    

    These settings will change at MySQL Restart.


    For permanent changes add below line in my.cnf and restart MySQL.

    max_connections = 151
    

提交回复
热议问题