Signup
DATABASE PROGRAMMING AND ADMINISTRATION FORUM
Top Web Hosts >> Forums >> Database Programming and Administration

   
  MySQL spits "Too many connections" error
  Name : aladar     Date : 06-11-15 16:50     Hit : 3799    
  Trackback : http://www.topwebhosts.org/bbs/tb.php/database/5
If you have too many connections on the MySQL database, you may reach a limit and no new connections can be created. The default connection limit is 100, and you may use max_connections system variable to increase the size. To see the current max_connections size, connect to the mysql and type the following commane

mysql> show variables like 'max_connections';

+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 100 |
+-----------------+-------+
1 row in set (0.00 sec)


mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.

To diagnose this problem, type the following from the MySQL client session:

mysql> show processlist;

You will see all the connections that exists. Each connection is associated with an ID, and you'll use that ID to disconnect (or kill) the connections.

mysql> kill 3004512;

To increase the max_connections and max_user_connections, please edit the /etc/my.cnf file and add the following statements.

[mysqld]
max_connections=300

It is always helpful to check your code and make sure all mysql connections are being closed properly, and change from mysql_pconnect to mysql_connect. The pconnect may not give you much speed advantage if connecting to a local mysql server.

scott   08-02-09 14:19
On Ubuntu, the my.cnf is located in /etc/mysql/my.cnf.
   

 


Cheap Web HostingBudget Web HostingEcommerce Web Hosting
Link to UsLink ExchangeAdvertisePrivacy PolicyTerms Of ServiceAbout UsContact UsSitemap
Copyright © 2006 - 2013 Broadband Media, Inc. All rights reserved.