title: How to set max_connections in MySQL Programmatically
body: <p>I have a server where a lot of users will connect to it and use a database there, and I am using MySQL. I know that the default number of <code>max_connections</code> in MySQL is 100 or 150 but I am sure I need way beyond that number, therefore I used the following to increase the number:</p>
  
  <pre><code>SET global max_connections = 1000000
  </code></pre>
  
  <p>Now I try to check the <code>max_connections</code> as follows:</p>
  
  <pre><code>show variables like 'max_connections'
  </code></pre>
  
  <p>It gives me the following:</p>
  
  <pre><code>max_connections; 100000;
  </code></pre>
  
  <p>Which is a sign that it succeeded (unless I am understanding it wrong). When my users start to connect I am receiving an error from the server when the number of connected users exceeds 110. The error is:</p>
  
  <blockquote>
    <p>error connecting: Timeout expired.  The timeout period elapsed prior
    to obtaining a connection from the pool.  This may have occurred
    because all pooled connections were in use and max pool size was
    reached.</p>
  </blockquote>
  
  <p>Why am I getting this error, and how to fix it?</p>