MySQL max connections setting

Sometimes, your MySQL client faces thsi error:

MySQL: ERROR 1040: Too many connections

To  get current max connections setting

show variables like "%max_connections%";

Result

max_connections	151
mysqlx_max_connections	100	

Default value is 151.

To update value in the current session

Note: the value will be reset when server restarts

set global max_connections = 512;

To get list of current connections

show processlist;

To set the setting permanently

In /etc/my.cnf:

max_connections = 512
/etc/my.cnf