Skip to main content

Concurrent mysql connections

Comments

5 comments

  • cPRex Jurassic Moderator
    Hey there! There's no way to do this unless you're using CloudLinux with the MySQL Governor tool. Just cPanel alone doesn't have these type of limits in place. You can read more about MySQL Governor here: CloudLinux - Restricting MySQL usage resources with MySQL Governor - CloudLinux
    0
  • Ramon E Navas R
    Thanks for the reply.
    0
  • cPRex Jurassic Moderator
    You're welcome!
    0
  • bellwood
    Would the following not work in /etc/my.cnf: max_connections = 500 max_user_connections = 25
    ...where 500 would be the maximum connection limit to the daemon (whatever you deem appropriate for your deployment) and 25 would be the max connections per user: REF: MySQL :: MySQL 5.7 Reference Manual :: 6.2.16 Setting Account Resource Limits
    0
  • Takito
    I have something to add, in case others will need it. max_connections = 500
    can be changed in WHM > SQL Services > Edit SQL Configuration max_user_connections = 25, I didn't have this in /etc/my.cnf and when added the load increased dramatically after some time, MySQL started to crash. Maybe the reason was that in Cloudlinux DB governor I had lower number of connections and max_user_connections overrides Cloudlinux settings, I don't know. When I removed it everything went back to normal. Another thing, at first I thought this command(and the same above max_user_connections) limits cpanel user, but it actually limits database user inside a cpanel account. In my case, one cpanel account had 30+ MySQL users and this thing doesn't help at all. ALTER USER 'specificUser'@'localhost' WITH MAX_USER_CONNECTIONS 25;
    In this case you need to limit each DB user separately. Here is the command to list all users in the proper format to limit them SELECT con cat("ALTER USER '", `user`, "'@'localhost' WITH MAX_USER_CONNECTIONS 1;") FROM `mysql`.`user`
    ("concat" should be together, the forum won't let me use it here) If using phphmyadmin then click "options" below, full text, go. Then copy the needed user/s and execute the command. Setting connections to 1 reduced the load significantly in my case.
    0

Please sign in to leave a comment.