我在my.cnf中设置参数
log = /tmp/mysqld.sql用来记录目前数据库中执行的sql语句,现在因为这个mysqld.sql文件过大,我想清空里面的内容重新记录sql日志,但是试用flush logs却清空不了,请问应该如何对这样的日志进行清空,谢谢。
log = /tmp/mysqld.sql用来记录目前数据库中执行的sql语句,现在因为这个mysqld.sql文件过大,我想清空里面的内容重新记录sql日志,但是试用flush logs却清空不了,请问应该如何对这样的日志进行清空,谢谢。
shell> mv host_name.log host_name-old.log
shell> mysqladmin flush-logs
shell> cp host_name-old.log backup-directory
shell> rm host_name-old.log
Before 5.1.3, you cannot rename a log file on Windows while the server has it open. You must stop the server and rename the file, and then restart the server to create a new log file. As of 5.1.3, this applies only to the error log. However, a stop and restart can be avoided by using FLUSH LOGS, which causes the server to rename the error log with an -old suffix and open a new error log.
As of MySQL 5.1.12, you can disable the general query log at runtime:
SET GLOBAL general_log = 'OFF';
With the log disabled, rename the log file externally; for example, from the command line. Then enable the log again:
SET GLOBAL general_log = 'ON';
This method works on any platform and does not require a server restart.
1.rm -rf mysqld.sql
2.vi mysqld.sql
3.chown mysql:mysql mysqld.sql不知道这样做是否可以。
不过最简单的应该是1楼说的那样 直接删除就可以了