系统是centOS5.2 + mysql5.0.45
在my.cnf里加入了log-bin但是并没有指定路径
文档上说默认情况下和数据文件存放在同一个目录,我的数据目录是/var/lib/mysql/下,但是我并没有找到日志文件,只在/var/run/mysqld/下找到了日志文件,用find命令查找也只有/var/run/mysqld/下有日志文件,其他文件夹没找到
为什么我的日志文件默认位置和文档上说的不一样?

解决方案 »

  1.   

    看一下你的变量
    show variables like 'log_bin';
    show variables like 'datadir';
      

  2.   

    默认是在你的 datadir 目录下mysql> show variables like 'datadir';
    +---------------+-----------------------------------------------+
    | Variable_name | Value                                         |
    +---------------+-----------------------------------------------+
    | datadir       | C:\Program Files\MySQL\MySQL Server 5.1\DATA\ |
    +---------------+-----------------------------------------------+
    1 row in set (0.00 sec)mysql>
      

  3.   

    mysql> show variables like 'log_bin';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | log_bin       | ON    |
    +---------------+-------+
    1 row in set (0.03 sec)mysql> show variables like 'datadir';
    +---------------+-----------------+
    | Variable_name | Value           |
    +---------------+-----------------+
    | datadir       | /var/lib/mysql/ |
    +---------------+-----------------+
    1 row in set (0.00 sec)
      

  4.   

    在my.cnf里加入了log-bin但是并没有指定路径 ---------------
    这样的话,照道理应该在datadir目录下的哦,像你这样的问题好奇怪哦
    要不这样吧
    你看看err错误日志是在哪?还可以试着打开“通用查询日志”(log)看看文件生成在哪吧
      

  5.   

    | datadir     | /var/lib/mysql/ |你的数据目录是在 /var/lib/mysql/建议你 variables like '%log%'; 看一下。
      

  6.   

    试过了,都是在/var/run/mysqld/下,而不是在应该在的数据目录下
      

  7.   

    配置文件里没有规定名字,使用默认的名字
    /var/run/mysqld/下自动生成的是bin-log.000001,bin-log.index
      

  8.   

    这是配置文件[mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysqllog-bin
    log
    log-slow-queries
    log-warnings# Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1[mysqld_safe]
    log-error
    pid-file=/var/run/mysqld/mysqld.pid
    ~
      

  9.   

    奇怪,看起来像是与pid-file设置相关,去掉pid-file=/var/run/mysqld/mysqld.pid呢?
      

  10.   

    When started with the --log-bin[=base_name] option, mysqld writes a log file containing all SQL statements that update data (both DDL and DML statements). If no base_name value is given, the default name is the value of the pid-file option (which by default is the name of host machine) followed by -bin. If the basename is given, but not as an absolute path name, the server writes the file in the data directory. 文档上是如此说!
    If no base_name value is given, the default name is the value of the pid-file option (which by default is the name of host machine) followed by -bin.
    当你未指定时,binlog 会放在 pid-file 值对应位置。
      

  11.   

    而中文版中的说明则是当用--log-bin[=file_name]选项启动时,mysqld写入包含所有更新数据的SQL命令的日志文件。如果未给出file_name值, 默认名为-bin后面所跟的主机名。如果给出了文件名,但没有包含路径,则文件被写入数据目录。 If no base_name value is given, the default name is the value of the pid-file option (which by default is the name of host machine) followed by -bin. If the basename is given, but not as an absolute path name, the server writes the file in the data directory. 中文翻译好象漏掉了这一句。
      

  12.   

    By default, all log files are created in the mysqld data directory
    文档中也有这么一句话,就是MySQL Server Logs这一章刚开始If no file_name value is given for --log or -l, the default name is host_name.log in the data directory
    这句话出现在文档中The General Query Log这一节,文档描述和我实际测试不符If no file_name value is given for --log-slow-queries, the default name is host_name-slow.log. If a file name is given, but not as an absolute path name, the server writes the file in the data directory.
    这句话出现在文档The Slow Query Log这一节,也不符合不过中文翻译的确很有问题我现在觉得可能和这句话有关If no base_name value is given
      

  13.   

    哦,原来真在pid-file下了
    不错
      

  14.   

    测试了一下,如果只是指定log-bin后面参数都没有,日志会存放在pid-file目录,如果指定了文件名而没有指定具体的文件夹,如log-bin=binlog,binlog.000001,binlog.index会出现在数据文件所在目录,log和log-slow-queries同样如此。
    文档中的话
    When started with the --log-bin[=base_name] option, mysqld writes a log file containing all SQL statements that update data (both DDL and DML statements). If no base_name value is given, the default name is the value of the pid-file option (which by default is the name of host machine) followed by -bin. If the basename is given, but not as an absolute path name, the server writes the file in the data directory
    应该理解为:如果base_name没有给出,默认为pid-file的名字后面加上-bin作为binlog的名字,如果basename给出但没有绝对路径名,binlog会放在数据文件所在目录慢查询日志同样如此
    To enable the slow query log, start mysqld with the --log-slow-queries[=file_name] option. If no file_name value is given for --log-slow-queries, the default name is host_name-slow.log. If a file name is given, but not as an absolute path name, the server writes the file in the data directory. 至于通用查询日志手册中的描述
    To enable the general query log, start mysqld with the --log[=file_name] or -l [file_name] option. If no file_name value is given for --log or -l, the default name is host_name.log in the data directory
    这句话我估计少了一句If a file name is given, but not as an absolute path name
    我看的是5.0的官方手册
      

  15.   

    所以Google到所有资料几乎全都是说:日志文件默认存放在数据文件所在目录。不能说错误,至少是不准确的