小墨の博客

梦想需要付诸行动,否则只能是梦

MySQL 5.7 binlog 开启及日志内容查看

MySQL 5.7 binlog 开启及日志内容查看

一、如何开启

5.7版本,直接在配置文件中指定:

[mysqld]
log-bin=mysql-bin
server-id=1
binlog_format=ROW

官网:

16.1.2.1 Setting the Replication Master Configuration

To configure a master to use binary log file position based replication, you must enable binary logging and establish a unique server ID. If this has not already been done, a server restart is required.

Binary logging must be enabled on the master because the binary log is the basis for replicating changes from the master to its slaves. If binary logging is not enabled on the master using the log-bin option, replication is not possible.

Each server within a replication group must be configured with a unique server ID. This ID is used to identify individual servers within the group, and must be a positive integer between 1 and (232)−1. How you organize and select the numbers is your choice.

To configure the binary log and server ID options, shut down the MySQL server and edit the my.cnf or my.ini file. Within the [mysqld] section of the configuration file, add the log-bin and server-id options. If these options already exist, but are commented out, uncomment the options and alter them according to your needs. For example, to enable binary logging using a log file name prefix of mysql-bin, and configure a server ID of 1, use these lines:

[mysqld]
log-bin=mysql-bin
server-id=1

After making the changes, restart the server.


二、查看binlog文件

1、mysql> show variables like '%log_bin%';

519126-20190226151835444-831701154.png


2、查看目录

519126-20190226151959566-1743055764.png


3、查看当前正在写入的binlog文件

show master status;

519126-20190226152142140-1165337036[1].png


4、mysql> show binlog events;

查看当前正在写入的日志文件中的binlog事件(看不出具体内容,只能看个大概)

519126-20190226152505286-94012629.png


5、mysql> show binlog events in 'mysql-bin.000001';

查看指定的文件

内容同上。


6、mysql> show binary logs;

显示文件列表。

519126-20190226152646717-1303723606.png


7、用mysqlbinlog查看binlog详情

https://www.cnblogs.com/snifferhu/p/5280489.html

https://www.cnblogs.com/lvzf/p/10689462.html


参考:https://www.cnblogs.com/grey-wolf/p/10437811.html

张小弟之家

本文链接:
文章标题:

本站文章除注明转载/出处外,均为原创,若要转载请务必注明出处。转载后请将转载链接通过邮件告知我站,谢谢合作。本站邮箱:admin@only4.work

尊重他人劳动成果,共创和谐网络环境。点击版权声明查看本站相关条款。

    发表评论:

    搜索
    本文二维码
    标签列表
    站点信息
    • 文章总数:512
    • 页面总数:20
    • 分类总数:92
    • 标签总数:208
    • 评论总数:62
    • 浏览总数:235404

    | | |
    | |  Z-Blog PHP