Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How to optimize my MySQL query to use less mysql connection?

Discussion in 'Workarounds and Optimization' started by Nirjonadda, Apr 25, 2015.

  1. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    595
    Likes Received:
    15
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    I am getting database error via email. Please let me know, How to fixing on this issue?

    Is my default settings, max_connections=800 and max_user_connections = 50, I wonder what is good parameter to set for max_user_connection for VPS?

    Code:
    Database error in vBulletin :
    mysqli_real_connect(): (42000/1203): User nadda_data already has more than 'max_user_connections' active connections
    
    User nadda_userdata already has more than 'max_user_connections' active connections
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,788
    Likes Received:
    82
    Trophy Points:
    78
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    max_user_connections value is totally depend on your server configuration and site traffic. You will need to change that with site traffic and VPS configurations. But I will suggest you please discuss this issues with your site developer . Your developer will optimize your MySQL query to use less mysql connection
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    595
    Likes Received:
    15
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    Please can you let me know, How to optimize my MySQL query to use less mysql connection? what is good parameter to set for optimize?

    This is my default my.cnf settings.

    Code:
    [mysqld]
    local-infile=0
    
    max_connections=800
    max_user_connections = 50
    datadir="/var/lib/mysql"
    socket          = "/var/lib/mysql/mysql.sock"
    
    key_buffer = 256M
    table_cache = 28560
    open_files_limit=50000
    join_buffer_size = 2M
    read_buffer_size = 2M
    sort_buffer_size = 6M
    tmp_table_size=128M
    read_rnd_buffer_size=4M
    max_heap_table_size=64M
    myisam_sort_buffer_size=64M
    thread_cache_size=8
    thread_cache=512
    query_cache_limit=12M
    query_cache_size=256M
    thread_concurrency = 8
    wait_timeout=1000
    connect_timeout=1000
    interactive_timeout=1000
    #log-slow-queries = /var/log/mysqlslowqueries.log
    max_allowed_packet=268435456
    
    default-storage-engine=MyISAM
    innodb_file_per_table=1
    [isamchk]
    key_buffer =64M
    sort_buffer_size = 64M
    read_buffer = 16M
    write_buffer = 16M
    
    [myisamchk]
    key_buffer = 64M
    sort_buffer_size = 64M
    read_buffer = 16M
    write_buffer = 16M
    
    [mysqlhotcopy]
    interactive-timeout
    [mysqld_safe]
    
    log-error="/var/log/mysqld.log"
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. LostNerd

    LostNerd Well-Known Member

    Joined:
    Mar 12, 2014
    Messages:
    258
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Hastings, East Sussex, UK
    cPanel Access Level:
    Root Administrator
    Twitter:
    Considering that your access level is "Website Owner", I am assuming that you don't administrate the server to increase the limit? The best way to reduce connections in your case is to have your web developer optimize his/her queries and joining them together...

    What I do, for example if pulling the information from the same row regularly, I'll dump it into an array so that it only has to make one connection per page load. :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,672
    Likes Received:
    1,788
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice