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
ormy.ini
file. Within the[mysqld]
section of the configuration file, add thelog-bin
andserver-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 ofmysql-bin
, and configure a server ID of 1, use these lines:[mysqld] log-bin=mysql-bin server-id=1After making the changes, restart the server.
二、查看binlog文件
1、mysql> show variables like '%log_bin%';
2、查看目录
3、查看当前正在写入的binlog文件
show master status;
4、mysql> show binlog events;
查看当前正在写入的日志文件中的binlog事件(看不出具体内容,只能看个大概)
5、mysql> show binlog events in 'mysql-bin.000001';
查看指定的文件
内容同上。
6、mysql> show binary logs;
显示文件列表。
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
尊重他人劳动成果,共创和谐网络环境。点击版权声明查看本站相关条款。