title: How to increase the max_connections value for MySQL on Ubuntu Server?
body: <p>I use MySQL <code>5.6</code> on Ubuntu Server <code>14.04</code> and want to increase the maximal allowed number of simultaneous connections (currently set to default <code>151</code>).</p>
  
  <p>Responsible for this is the setting <code>max_connections</code> in the <code>/etc/mysql/my.cnf</code>. So I set it to <code>200</code> and restarted the MySQL server. Now, it has the value <code>200</code>:</p>
  
  <pre><code>$ cat /etc/mysql/my.cnf | grep "connections"
  max_connections        = 200
  $ /etc/init.d/mysql restart
   * Stopping MySQL database server mysqld                                                                                             [ OK ] 
   * Starting MySQL database server mysqld                                                                                             [ OK ] 
   * Checking for tables which need an upgrade, are corrupt or were 
  not closed cleanly.
  </code></pre>
  
  <p>But nothing has changed:</p>
  
  <pre><code>SHOW VARIABLES LIKE "max_connections";
  +-----------------+-------+
  ¦ Variable_name   ¦ Value ¦
  +-----------------+-------+
  ¦ max_connections ¦ 151   ¦
  +-----------------+-------+
  </code></pre>
  
  <p><strong>How to get the custom configuration of <code>max_connections</code> working?</strong></p>
  
  <hr>
  
  <pre><code>$ ulimit -a | grep "open"
  open files                      (-n) 1024
  $ ulimit -n 4096
  $ ulimit -a | grep "open"
  open files                      (-n) 4096
  </code></pre>
  
  <p>added to the <code>/etc/security/limits.conf</code>:</p>
  
  <pre><code>* soft nofile 1024000
  * hard nofile 1024000
  * soft nproc 10240
  * hard nproc 10240
  root soft nproc unlimited
  </code></pre>
  
  <p>added to the <code>/etc/mysql/my.cnf</code>:</p>
  
  <pre><code>[mysqld_safe]
  open_files_limit = 1024000
  [mysqld]
  open_files_limit = 1024000
  </code></pre>
  
  <p>But it seems to be ignored:</p>
  
  <pre><code>SHOW STATUS LIKE 'open%';
  +--------------------------+-------+
  ¦ Variable_name            ¦ Value ¦
  +--------------------------+-------+
  ¦ Open_files               ¦ 52    ¦
  +--------------------------+-------+
  ¦ Open_streams             ¦ 0     ¦
  +--------------------------+-------+
  ¦ Open_table_definitions   ¦ 434   ¦
  +--------------------------+-------+
  ¦ Open_tables              ¦ 417   ¦
  +--------------------------+-------+
  ¦ Opened_files             ¦ 847   ¦
  +--------------------------+-------+
  ¦ Opened_table_definitions ¦ 0     ¦
  +--------------------------+-------+
  ¦ Opened_tables            ¦ 0     ¦
  +--------------------------+-------+
  </code></pre>
  
  <p>To avoid the case of setting the correct configs in wrong files I set the option in all these files (some of them was not there, so I created them):</p>
  
  <pre><code>$ mysqld --help --verbose | grep -B 1 cnf
  Default options are read from the following files in the given order:
  /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
  </code></pre>
  
  <p>No effect.</p>