title: CodeIgniter too many connections
body: <p>Suddenly my project starts saying there's too many connections to the database.</p>
  
  <blockquote>
    <p>"my_mysql_user already has more than 'max_user_connections' active
    connections"</p>
  </blockquote>
  
  <p>This always worked fine and I'm using multidatabase and the settings are</p>
  
  <pre><code>$config['hostname'] = 'localhost';
  $config['username'] = 'my_mysql_user';
  $config['password'] = 'my_mysql_password';
  $config['database'] = ($db == null ? $this-&gt;CI-&gt;session-&gt;company['db'] : $db);
  $config['dbdriver'] = 'mysqli';
  $config['dbprefix'] = '';
  $config['pconnect'] = FALSE;
  $config['db_debug'] = FALSE;
  $config['char_set'] = 'utf8';
  $config['dbcollat'] = 'utf8_general_ci';
  </code></pre>
  
  <p>And I need to load like 20/30 models..and I always load them in the <code>__construct()</code> of the controller. </p>
  
  <p>Even thought it always worked, I thought I might change it and load the models only in the functions that are needed, and the problem persists.</p>
  
  <p>By executing <code>SHOW PROCESSLIST</code> it returns nothing, there's no query being done.</p>
  
  <p>What can I do to track the problem? It seems the connections are not closed!</p>