mysql5.7版本 binlog 开启及日志内容查看

发布时间:2026/6/4 16:18:39

mysql5.7版本 binlog 开启及日志内容查看 一、如何开启#5.7版本直接在配置文件中指定[mysqld] log-binmysql-bin server-id1 binlog_formatROW官网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 loggingmustbe 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 thelog-binoption, 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 themy.cnformy.inifile. Within the[mysqld]section of the configuration file, add thelog-binandserver-idoptions. 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-binmysql-bin server-id1After 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详情MySQL的binlog数据如何查看 - 潦草白纸 - 博客园mysqlbinlog 工具分析binlog日志 - 吕忠峰 - 博客园我这边尝试了一下我先修改了一条记录如下是修改前file_url是xxxxxx修改后如下接下来我们查看binlog中对于本次修改的具体内容mysqlbinlog --base64-outputAUTO -v -d cad binlog.000023如果不熟悉这些命令的选项可以man mysqlbinlog查看。8、查看binlog相关参数show variables like %binlog%;标红的都是我目前知道的比较重要的。在innodb存储引擎那本书里重点说了下面的几个参数也很值得了解下

相关新闻