I need to change max_connections parameter in /etc/my.cnf. After doing the change, do we need to restart mysqld service to apply the changes? I'm on CentOS 7

1 Answer 1


Some server parameters are dynamic and can be changed on the fly. Some are not and should be configured in the my.cnf followed by service restart. max_connections can be changed on the fly by command SET GLOBAL max_connections=XXX. This value will be in effect until service restart.

To be clear, the possible options are:

  • Run SET GLOBAL max_connections = XXX for immediate use until service restarted
  • Add the max_connections = XXX line to the [mysqld] section of the my.cnf AND restart the service for permanent use
  • Run SET GLOBAL max_connections = XXX AND add the max_connections = XXX line to the my.cnf but DO NOT restart the service.

The third option allows to get both immediate changes as well as permanent but with zero downtime. Value in the my.cnf will wait for some event/incident/accident causing a service's restart.

  • To make the ``` max_connections ``` parameter change permanent, we need to restart the service, right? Jun 22, 2020 at 12:29
  • 1
    @PradeepSanjeewa Right. Placed in my.cnf this value becomes permanent, but you do not need to restart the serveice immediately. You can set it dynamically for immediate use and change it in the my.cnf where it will postponed until restart.
    – Kondybas
    Jun 22, 2020 at 12:42
  • 1
    And MySQL 8.0 has a SET PERSIST ...
    – Rick James
    Jun 24, 2020 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.