How to Rotate MySQL Slow Query Log
With MySQL, you can analyze and interpret errors and performance from a number of automatically created logs. As with any type of file, the larger it gets, the slower and more error-prone it gets. Therefore, it is necessary to rotate the log files, so that you have empty logs at regular intervals. On Red Hat Linux, the mysql-log-rotate script automatically does this for you, but with any other Linux distribution, you have to rotate the logs manually. This is a quick process, but it requires access via the secure shell (SSH).
Instructions
-
-
1
Log in to your web server via SSH to open a command line prompt. If you are unsure if this is enabled, check with your webhost.
-
2
Type "cd mysql-data-directory" and press "Enter."
-
-
3
Type "mv mysql.log mysql.old" and press "Enter."
-
4
Type "mv mysql-slow.log mysql-slow.old" and press "Enter."
-
5
Type "mysqladmin flush-logs" and press "Enter." This starts a new log, keeping your old logs suffixed with the ".old" suffix. For each subsequent log rotation, change the extension to .log2, .log3 and so on.
-
1