Mysql/Maria DB – Too many open files

Solution how to fix following error generated in /var/log/syslog by mysqld service on Ubuntu 16.04 with MariaDB 10.0.x:

mysqld: 181210 [ERROR] Error in accept: Too many open files

If you see message above you probably reached default limits of mysqld service. To set open files parameter limit as unlimited, follow steps below:

  • Login as root:
sudo -i
  • Modify /etc/security/limits.conf:
nano /etc/security/limits.conf
  • And set mysql soft and hard limit for nofiles:

mysql soft nofile 65535
mysql hard nofile 65535

# End of file
  • Save modified limits.conf and Reboot system:
sudo reboot
  • Create mysql.service.d folder to customize startup parameters and create limits.conf file:
mkdir -p /etc/systemd/system/mysql.service.d/
nano /etc/systemd/system/mysql.service.d/limits.conf
  • Into limits.conf insert following:
  • Save file and restart mysqld service:
systemctl daemon-reload
/etc/init.d/mysql restart
  • Check new limits of mysqld process:
cat /proc/$(cat /var/run/mysqld/
  • Desired state after change:
Limit                     Soft Limit           Hard Limit           Units
Max open files            1048576              1048576              files
  • By default mariadb has following:
Limit                     Soft Limit           Hard Limit           Units
Max open files            1024                 4096                 files


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.