Search code examples
mysqldatabasesocketsdatabase-connection

How to increase MySQL connections(max_connections)?


Every socket of MySQL Database will have defaults connections as 100 but I am looking for any way to increase the number of possible connections > 100 to a socket connection of MySQL Database.


Solution

  • If you need to increase MySQL Connections without MySQL restart do like below

    mysql> show variables like 'max_connections';
    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 100   |
    +-----------------+-------+
    1 row in set (0.00 sec)
    
    mysql> SET GLOBAL max_connections = 150;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show variables like 'max_connections';
    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 150   |
    +-----------------+-------+
    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 = 150