The max_connections in MySQL 5.7
You may set the value manually, e.g.
set global max_connections=500;
however, after a restart of MySQL the value is reset to 214.
The solution depends on the (version of) OS and the MySQL version. With Ubuntu 16.04 and MySQL >= 5.7.7 following works:
systemctl edit mysql
Enter
[Service]
LimitNOFILE=8000
save, this will create a new file
/etc/systemd/system/mysql.service.d/override.conf
and restart the server:
systemctl daemon-reload
systemctl restart mysql
For other environments: Can not increase max_open_files for Mysql max-connections in Ubuntu 15
As MySQL documentation on max_connections setting says:
Increasing this value increases the number of file descriptors that mysqld requires. If the required number of descriptors are not available, the server reduces the value of max_connections.
This means that probably your MySQL server does not have enough resources to maintain the required number of descriptors.
MySQL documentation on How MySQL Opens and Closes Tables makes it clear that:
The table_open_cache and max_connections system variables affect the maximum number of files the server keeps open. If you increase one or both of these values, you may run up against a limit imposed by your operating system on the per-process number of open file descriptors. Many operating systems permit you to increase the open-files limit, although the method varies widely from system to system. Consult your operating system documentation to determine whether it is possible to increase the limit and how to do so.