The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Too many connections in Mysql

Discussion in 'General Discussion' started by kde_tony, Feb 26, 2008.

  1. kde_tony

    kde_tony Registered

    Joined:
    Feb 5, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
  2. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    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
     
  3. kde_tony

    kde_tony Registered

    Joined:
    Feb 5, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  4. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    post your entire my.cnf
     
  5. kde_tony

    kde_tony Registered

    Joined:
    Feb 5, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  6. XzaB

    XzaB Active Member

    Joined:
    Nov 20, 2005
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Egypt, Cairo

    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
     
  7. viraj

    viraj Well-Known Member

    Joined:
    Sep 28, 2006
    Messages:
    209
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    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... :)
     
  8. Zion Ahead

    Zion Ahead Well-Known Member

    Joined:
    Nov 10, 2006
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16
    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
     
Loading...

Share This Page