Edit the main MySQL configuration file(s) under /etc/mysql, and make the following changes. The exact files to edit vary by MySQL version and Linux distribution.

Add to [mysqld_safe]

open-files-limit = 65535

Add to [mysqld]

expire_logs_days = 7
innodb_flush_log_at_trx_commit = 0
innodb_log_file_size = 64M
max_connections = 1000
max_user_connections = 990
net_write_timeout = 28800
table_open_cache = 1024
wait_timeout = 172800

In addition, add the following line to the [mysqld] section on larger systems (1000 concurrent calls or more) if memory allows:

innodb_buffer_pool_size = 20G

Only if using MySQL 5.7.x or older 5.x version (but not MySQL 8.x), add to [mysqld]

query-cache-size = 256M

Only if using MariaDB or MySQL 5.7.x with a version newer than 5.7.5, add to [mysqld]

sql_mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Only if using MySQL 8.x or newer, add to [mysqld]

innodb_numa_interleave = on
sql_mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
default-authentication-plugin = mysql_native_password

If using systemd

  • systemctl edit mysql # for Debian based platforms
  • systemctl edit mysqld # for Fedora, CentOS and RHEL platforms
  • Add the following lines to the edited file and save it:
    			[Service]
    			LimitNOFILE=65535
    		
  • systemctl daemon-reload