MySQL 的版本为
mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using EditLine wrapper
打开配置文件
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
在 mysqld 下面加上以下参数
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 30
max_binlog_size = 100M
binlog_format = ROW
重启 mysql 服务
sudo service mysqld restart
查看是否配置成功
mysql -u root -p -e "show global variables like '%log_bin%';"
其中 log_bin 显示 ON 表明配置成功
+---------------------------------+--------------------------------+
| Variable_name | Value |
+---------------------------------+--------------------------------+
| log_bin | ON |
| log_bin_basename | /var/log/mysql/mysql-bin |
| log_bin_index | /var/log/mysql/mysql-bin.index |
+---------------------------------+--------------------------------+