欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

mac 开启mysql bin-log

程序员文章站 2022-07-09 19:45:38
添加以下配置 // 重启mysql 查看是否开启 ; 查看日志状态 ; 刷新日志,刷新之后会新建一个新的Binlog日志 清空目录下所有日志文件 查看日志文件: bash / !50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1 /; / !50003 SET @OLD_ ......

vim /usr/local/etc/my.cnf 添加以下配置

expire_logs_days = 5 定期清理
log-bin = /usr/local/var/mysql/mysql_bin_log/mysql-bin #开启binlog,指定文件闻之
server_id = 1 #配置mysql replication需要定义,不能和canal的slaveid重复
binlog_format=mixedd

mysql.server restart // 重启mysql

show variables like '%log_bin% 查看是否开启

show master status; 查看日志状态

flush logs; 刷新日志,刷新之后会新建一个新的binlog日志

reset master 清空目录下所有日志文件

查看日志文件:mysqlbinlog --base64-output=decode-rows -v mysql-bin.000001

/*!50530 set @@session.pseudo_slave_mode=1*/;
/*!50003 set @old_completion_type=@@completion_type,completion_type=0*/;
delimiter /*!*/;
# at 4
#200423 16:43:25 server id 1  end_log_pos 123 crc32 0xb303c132     start: binlog v 4, server v 5.7.29-log created 200423 16:43:25 at startup
# warning: this binlog is either in use or was not closed properly.
rollback/*!*/;
# at 123
#200423 16:43:25 server id 1  end_log_pos 154 crc32 0x21d20383     previous-gtids
# [empty]
# at 154
#200423 16:45:11 server id 1  end_log_pos 219 crc32 0xfb334efd     anonymous_gtid    last_committed=0    sequence_number=1    rbr_only=no
set @@session.gtid_next= 'anonymous'/*!*/;
# at 219
#200423 16:45:11 server id 1  end_log_pos 295 crc32 0xb8e6b396     query    thread_id=4    exec_time=0    error_code=0
set timestamp=1587631511/*!*/;
set @@session.pseudo_thread_id=4/*!*/;
set @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
set @@session.sql_mode=1436549152/*!*/;
set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\c utf8 *//*!*/;
set @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
set @@session.lc_time_names=0/*!*/;
set @@session.collation_database=default/*!*/;
begin
/*!*/;
# at 295
#200423 16:45:11 server id 1  end_log_pos 626 crc32 0xa15900c0     query    thread_id=4    exec_time=0    error_code=0
use `chunyu`/*!*/;
set timestamp=1587631511/*!*/;
update `article_article` set `created_time` = '2020-04-23 08:17:20.953805', `last_modified` = '2020-04-23 08:45:11.324532', `user_id` = 1, `title` = '1', `content` = '999999', `status` = 1, `comment_count` = 0, `star_count` = 0 where `article_article`.`id` = 2
/*!*/;
# at 626
#200423 16:45:11 server id 1  end_log_pos 657 crc32 0xeb7a6863     xid = 14
commit/*!*/;
set @@session.gtid_next= 'automatic' /* added by mysqlbinlog */ /*!*/;
delimiter ;
# end of log file
/*!50003 set completion_type=@old_completion_type*/;
/*!50530 set @@session.pseudo_slave_mode=0*/;