Too many connections in Mysql

kde_tony

Registered
Feb 5, 2008
3
0
51
greetings, I have a problem with mysql, arrive reports to me from the system mysql: to many connections, wanted to know as I can solve it.
 

jayh38

Well-Known Member
Mar 3, 2006
1,212
0
166
if this is your server, you can increase the connections in my.cnf and set your limits

/etc/my.cnf

[mysqld]
max_user_connections=30
max_connections=500
 

kde_tony

Registered
Feb 5, 2008
3
0
51
when making the change in my.conf, adding the parament's, leaves an error to me in sock. And it cannot initiate mysqld. there is another aplication y/o modification.
thnks
 

kde_tony

Registered
Feb 5, 2008
3
0
51
im newbie in this of forum, my file my.conf. What top was reviewing using the command TOP, is that mysql, uses many resources, in the servant, soon, within mysql by console, I key in, show full processlist, and it leaves consultations to me the data base (already identified) that is very great, and when I want to kill the process, it does not leave me, says to me that the PID does not exist.

Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
 
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
#old_passwords=1
 
[mysql.server]
user=mysql
#basedir=/var/lib
 
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
 

XzaB

Active Member
Nov 20, 2005
35
0
156
Egypt, Cairo
im newbie in this of forum, my file my.conf. What top was reviewing using the command TOP, is that mysql, uses many resources, in the servant, soon, within mysql by console, I key in, show full processlist, and it leaves consultations to me the data base (already identified) that is very great, and when I want to kill the process, it does not leave me, says to me that the PID does not exist.

Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
 
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
#old_passwords=1
 
[mysql.server]
user=mysql
#basedir=/var/lib
 
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

so as Jayh38 said , you can replace you current config with this

Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
max_user_connections=30
max_connections=500
 
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
#old_passwords=1
 
[mysql.server]
user=mysql
#basedir=/var/lib
 
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

P.S :
max_user_connections=30 #you can increase and decrease the value of max_user_connections
max_connections=500 #you can increase and decrease the value of max_connections
 

viraj

Well-Known Member
Sep 28, 2006
209
3
168
India
cPanel Access Level
DataCenter Provider
Twitter
greetings, I have a problem with mysql, arrive reports to me from the system mysql: to many connections, wanted to know as I can solve it.
Hi, increasing the max_connection value solves the issue, but you may want to check if any of script are using persistent connection [mysql_pconnect()] and not releasing mysql connection then such errors are very frequent. If yes, please change that to mysql_connect(). Persistent connections may cause as such 'too many connections' issues, hence I'd recommend you to use mysql_connect() rather than mysql_pconnect(). One more thing I'd like to add is of getting the following mysql.allow_persistent=Off added into php.ini, this disables persistent connections server wide & will help you to get hold of the script causing this issue. Hopefully that fixes your issue... :)
 
  • Like
Reactions: psytanium

Zion Ahead

Well-Known Member
Nov 10, 2006
347
0
166
I have someone getting the below error message in vbulletin



Database error in vBulletin 3.6.8:

Invalid SQL:

UPDATE session
SET lastactivity = 1204930394, location = '/vb/admincp/email.php?do=dosendmail&do=dosendmail', inforum = 0, inthread = 0, incalendar = 0, badlocation = 0
WHERE sessionhash = 'b724956e03c6c0113ad12dfbb32d8bcb';

MySQL Error : MySQL server has gone away
Error Number : 2006
Date : Friday, March 7th 2008 @ 04:53:50 PM
Script : http://www.domain.com/vb/admincp/email.php?do=dosendmail
Referrer : http://www.domain.com/vb/admincp/email.php?do=start
IP Address : xxxxx
Username : xxxxx
Classname : vB_Database



/etc/my.cnf


Code:
#DO NOT MODIFY THE FOLLOWING COMMENTED LINES!
#Created with ELS from www.servermonkeys.com
#els-build=5.0
[mysqld]
datadir=/var/lib/mysql
skip-locking
#skip-innodb
#skip-networking
safe-show-database
query_cache_limit=1M
query_cache_size=128M ## 32MB for every 1GB of RAM
query_cache_type=1
max_user_connections=300
max_connections=500
interactive_timeout=30
wait_timeout=30
connect_timeout=30
thread_cache_size=128
key_buffer=512M ## 128MB for every 1GB of RAM
join_buffer=1M
max_connect_errors=20
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=4M ## 1MB for every 1GB of RAM
read_buffer_size=4M ## 1MB for every 1GB of RAM
read_rnd_buffer_size=4M  ## 1MB for every 1GB of RAM
thread_concurrency=8 ## Number of CPUs x 2
myisam_sort_buffer_size=64M
server-id=1
log_slow_queries=/var/log/mysql-slow-queries.log
long_query_time=2
collation-server=latin1_general_ci