自部署的mysql上开启binlog

  1. 查看mysql cnf文件所在位置
mysql --help
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /opt/homebrew/etc/my.cnf ~/.my.cnf
  1. 修改cnf文件,增加如下内容:
server-id         = 1
log_bin           = /tmp/mysql-bin
binlog_format     = ROW
binlog_row_image  = FULL
expire_logs_days  = 1
  1. 重启mysql服务

在aws rds for mysql上开启binlog

  1. rds dashboard上创建新的参数组,更改binlog_format为ROW

确认数据库是否已开启binlog,再次运行命令:

show variables like 'log_bin';
show variables like 'binlog_format';
  1. 修改rds示例配置。修改参数组为上面新建的;修改备份保留期为1天

  2. 设置binlog保存时长为24h

call mysql.rds_set_configuration('binlog retention hours', 24);
call mysql.rds_show_configuration;
  1. 重启实例