GoDaddy Help

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.

Warning: Logging MySQL queries can cause a heavy load on your server; and in some cases fill the disk. It's important that you disable logging once you are finished with your investigation.

Steps

  1. Login to your server through SSH as root.
  2. Edit the /etc/my.cnf file.
  3. vi /etc/my.cnf
  4. 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.log
    MySQL versions 5.5 and higher
    # Slow Query Log
    #slow_query_log=1
    #long_query_time=4
    #slow_query_log_file=/var/log/slow-queries.log
    MariaDB
    # Slow Query Log
    #slow_query_log
    #long_query_time=4
    #slow_query_log_file=/var/log/slow-queries.log
  5. Save the file and exit the editor.
  6. 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 restart
    CentOS 7
    systemctl mysqld restart
    systemctl mariadb restart
  7. Check the slow query log to make sure it isn't running.
    tail -f /var/log/slow-queries.log
    Let 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.

Related Steps

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.

More Info

To learn more about the hosting services GoDaddy offers, see our Hosting Services Menu.

Share this article