“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey
Senior Software Engineer, UK

MySQL - Too Many Connections Error

Getting Too Many Connections errors from MySQL. At the point where couldn’t determine why so many additional connections had appears from nowhere we had to immediately raise this limit. Fortunately you can do it while MySQL is still running.

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 300   |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> SET GLOBAL max_connections = 500;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 500   |
+-----------------+-------+
1 row in set (0.00 sec)

You can also check how many connections there are at a given time.

mysql> show status where `variable_name` = 'Threads_connected';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Threads_connected | 275   |
+-------------------+-------+
1 row in set (0.00 sec)

Be sure to memorialise your config change in my.cnf because restarting the server will loose this change.

[mysqld]
max_connections                 = 500
GPK of the Day Charred CHAD