In this tutorial we are going to see  “How one can solve too many connection problem in mysql using CodeIgniter”.  This error usually occurs if your scripts open persistent connections, which aren’t closed even if the script terminates, this means that all available connections are in use by other clients.

Now Exactly what are persistent connections..??  Persistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there’s already an identical persistent connection (that remained open from earlier) – and if it exists, it uses it. If it does not exist, it creates the link.

Steps To Resolve The Error:-

Step 1:  Use mysql_connect() instead of mysql_pconnect(). Here pconnect() states whether to use a persistent connection. To avoid using it in Codeigniter  goto your project folder and navigate to application/config/database.php file and change the setting as:

// Set ' pconnect' From TRUE  to  FALSE

$db['default']['pconnect'] = FALSE;

Step 2:  For Users who are using Server and wanted other sites to stop using persistent connection for PHP scripts, need to do the following change in their php.ini file:

; Allow or prevent persistent links.


Hope this tutorial resolved your  “MySql Too Many Connection Errors” problem.

Hope you like it, keep reading our other blogs. 🙂

For more related information just go through the following blogs –