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.

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:
    150
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Website Owner
    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
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,146
    Likes Received:
    34
    Trophy Points:
    48
    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
     
  3. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    150
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Website Owner
    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"
     
  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. :)
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page