Disable MySQL slow query logging
MySQL is one of the most popular database management systems used for database driven sites (like WordPress). It is crucial that you are able to investigate issues with MySQL on your VPS or Dedicated server. Logging MySQL queries can cause a heavy load on your server, so it's important that you disable logging once you are finished with your investigation.
- Login to your server through SSH as root.
- Edit the /etc/my.cnf file.
- Delete or comment out (#) the following lines in the [mysqld] section:
mysql versions < than 5.5
# Slow Query Log #set-variable=long_query_time=4 #log-slow-queries=/var/log/slow-queries.logMySQL versions 5.5 and higher
# Slow Query Log #slow_query_log=1 #long_query_time=4 #slow_query_log_file=/var/log/slow-queries.logMariaDB
# Slow Query Log #slow_query_log #long_query_time=4 #slow_query_log_file=/var/log/slow-queries.log
- Save the file and exit the editor.
- Restart the database service with the command appropriate to your enviornment.
CentOS 6 cPanel MySQL CentOS 6
service mysql restart service mysqld restart service mariadb restartCentOS 7
systemctl mysqld restart systemctl mariadb restart
- Check the slow query log to make sure it isn't running.
tail -f /var/log/slow-queries.logLet this run a few minutes to make sure nothing is being logged. You can use 'Ctrl-C' to terminate the command when you are finished.
GoDaddy Hosting Services
Our server experts can enable/disable MySQL slow query logging and optimize MySQL. To learn more about this service, our GoDaddy Guides are here to help.