Rotating the error log

Suppose the error log file has become bigger and you want to rotate it; you can simply move the file and execute the FLUSH LOGS command:

shell> sudo mv /var/log/mysql/mysqld.log /var/log/mysql/mysqld.log.0; shell> mysqladmin -u root -p<password> flush-logsmysqladmin: [Warning] Using a password on the command line interface can be insecure.shell> ls -lhtr /var/log/mysql/mysqld.log-rw-r-----. 1 mysql mysql 0 Oct 10 14:03 /var/log/mysql/mysqld.logshell> ls -lhtr /var/log/mysql/mysqld.log.0 -rw-r-----. 1 mysql mysql 3.4K Oct 10 14:03 /var/log/mysql/mysqld.log.0

You can automate the preceding steps using some scripts and put them into cron.

If the location of an error log file is not writable by the server, the log-flushing ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.