5.4.2.10 Error Log File Flushing and Renaming错误日志文件刷新和重命名

If you flush the error log using a FLUSH ERROR LOGS or FLUSH LOGS statment, or a mysqladmin flush-logs command, the server closes and reopens any error log file to which it is writing. 如果使用FLUSH ERROR LOGSFLUSH LOGS语句或mysqladmin flush-logs命令刷新错误日志,则服务器将关闭并重新打开正在写入的任何错误日志文件。To rename an error log file, do so manually before flushing. Flushing the logs then opens a new file with the original file name. 要重命名错误日志文件,请在刷新之前手动重命名。刷新日志,然后打开一个具有原始文件名的新文件。For example, assuming a log file name of host_name.err, use the following commands to rename the file and create a new one:例如,假设日志文件名为host_name.err,请使用以下命令重命名该文件并创建一个新文件:

mv host_name.err host_name.err-old
mysqladmin flush-logs
mv host_name.err-old backup-directory

On Windows, use rename rather than mv.在Windows上,使用rename而不是mv

If the location of the error log file is not writable by the server, the log-flushing operation fails to create a new log file. 如果服务器无法写入错误日志文件的位置,则日志刷新操作将无法创建新的日志文件。For example, on Linux, the server might write the error log to the /var/log/mysqld.log file, where the /var/log directory is owned by root and is not writable by mysqld. 例如,在Linux上,服务器可能会将错误日志写入/var/log/mysqld.log文件,其中/var/log目录为root所有,不可由mysqld写入。For information about handling this case, see Section 5.4.6, “Server Log Maintenance”.有关处理此情况的信息,请参阅第5.4.6节,“服务器日志维护”

If the server is not writing to a named error log file, no error log file renaming occurs when the error log is flushed.如果服务器没有写入命名的错误日志文件,则刷新错误日志时不会重命名错误日志文件。