Category: MySQL SQL

With CentOS 7 you need to increase file limits and file descriptors for max connections to work.

Increase Max File Limit

#Modify Following File
/etc/sysctl.conf

#Add following to file
fs.file-max = 100000

Increase Soft / Hard Limits

#Modify Following File
/etc/security/limits.conf

#Add following to file
soft nproc 65535
hard nproc 65535
soft nofile 65535
hard nofile 65535

mysql hard nofile 65535
mysql soft nofile 65535

#Commit the above settings
sysctl -p

Edit MySQL SystemD Service Limits

#Modify Following File
/usr/lib/systemd/system/mysqld.service

#Add following to file below [service
LimitNOFILE=65535
LimitNPROC=65535

#Reload the daemon with above settings
systemctl daemon-reload

Edit MySQL Configuration file with settings required:

#Modify following file: 
/etc/my.cnf

#Add following information (change if required)
open_files_limit = 1024
max_connections = 1000

#Restart MySQL to commit
systemctl restart mysqld

#Log into MySQL and run show variables like "max_connections"; to check max connections is correct

How useful was this post?

Click on a star to rate it!

Average rating 4.2 / 5. Vote count: 5

No votes so far! Be the first to rate this post.