Warning: mysql_connect() [function.mysql-connect]: Too many connections

Warning: mysql_connect(): Too many connections in /home/httpd/vhosts/example.com/public-html/connect.php on line 2 
Too many connections

This error means that all available connections are in use by other clients.It is possible that you have extremely high traffic on your website, however it is more likely that there connections to your database have been remaining open.

The variety of connections allowed is managed by the max_connections program variable. The standard value is 151 to enhance efficiency when MySQL is used with the Apache Web server.If you need to support more connections, you should set a higher value for this variable.

We may increase the limit by adding the below code in my.cnf file:

/etc/my.cnf
 max_connections = 500

 

 Then we may execute the SET GLOBAL max_connections = 500; in MySQL or  restart the MySQL service.