Experiencing MySQL crashes on your VPS now and then (or often)? The most probable cause is that it's bumping into the open files limit set by MySQL's default configuration options.
The standard open files limit stands at 1024. This works for a handful of websites, but when hosting numerous sites, this number needs a boost.
1. SSH into root
2. Enter: vi /etc/security/limits.conf
Adjust the lines to look like:
* soft nofile 1024000
* hard nofile 1024000
* soft nproc 10240
* hard nproc 10240
Save: Press Shift + ; then type wq!
3. Enter: vi /etc/security/limits.d/90-nproc.conf
Adjust the lines to look like:
* soft nofile 1024000
* hard nofile 1024000
* soft nproc 10240
* hard nproc 10240
root soft nproc unlimited
Save: Press Shift + ; then type wq!
4. Enter: ulimit -Hn 1024000
5. Enter: vi /etc/my.cnf
Add the following:
open_files_limit = 1024000
If there are sections [mysqld] and [mysqld_safe], place the line under both.
Save: Press Shift + ; then type wq!
6. Enter: service mysql restart