首页 > 代码库 > Window 下mysql binlog开启及查看

Window 下mysql binlog开启及查看

查看是否开启了binlog:

win+r => cmd => 连接mysql=>show variables like ‘log_%‘;   

mysql> show variables like 'log_%';
+---------------------------------+-------------+
| Variable_name                   | Value       |
+---------------------------------+-------------+
| log_bin                         | ON          |
| log_bin_trust_function_creators | OFF         |
| log_error                       | .\mysql.err |
| log_queries_not_using_indexes   | OFF         |
| log_slave_updates               | OFF         |
| log_slow_queries                | ON          |
| log_warnings                    | 1           |
+---------------------------------+-------------+
没有开启log_bin的值是OFF,开启之后是ON

开启binlog:

修改mysql配置文件 my.ini

添加配置:log-bin=log-bin=D:\AppServ/MySQL/log/mysql-bin.log   测试发现必须给全路径(名字随意给)

重启mysql 会在log目录下新增两个文件mysql-bin.000001与mysql-bin.index

查看binlog:

win+r => cmd => 连接mysql=> show binary logs; =>可以查看自己binlog的名称

win+r => cmd => 连接mysql=> show binlog events; =>可以查看已生成的binlog

导出成文本文件:

D:\AppServ\MySQL\bin>mysqlbinlog >d:/test.txt

确保在bin目录下有mysqlbinlog.exe 没有的话搜索下载

Window 下mysql binlog开启及查看