我在my.cnf中设置参数 
log = /tmp/mysqld.sql用来记录目前数据库中执行的sql语句,现在因为这个mysqld.sql文件过大,我想清空里面的内容重新记录sql日志,但是试用flush logs却清空不了,请问应该如何对这样的日志进行清空,谢谢。

解决方案 »

  1.   

    这个文件,只能直接删除,或者重命名,然后MYSQL会自动再生成一个新的。
      

  2.   

    http://dev.mysql.com/doc/refman/5.1/en/query-log.htmlServer restarts and log flushing do not cause a new general query log file to be generated (although flushing closes and reopens it). On Unix, you can rename the file and create a new one by using the following commands: 
    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. 
      

  3.   

    我现在是这样做的:
    1.rm -rf mysqld.sql
    2.vi mysqld.sql
    3.chown mysql:mysql mysqld.sql不知道这样做是否可以。
      

  4.   

    可以 不过你确认下mysql有没有继续往你里面写日志啊!
    不过最简单的应该是1楼说的那样  直接删除就可以了 
      

  5.   

    恩  已经OK了, 根据2楼的方法,先删除,然后再flush logs后会自动生成一个文件,谢谢。