mac下MYSQL5.7.20开启binlog日志

1、我的mysql是用brew install mysql 安装的

2、在/etc/下创建my.cnf 添加内容如下:

[mysqld]
#log_bin
log-bin = mysql-bin #开启binlog
binlog-format = ROW #选择row模式
server_id = 1 #配置mysql replication需要定义,不能和canal的slaveId重复

3、重启的时候最好是使用mysql.server restart 不然老是报更新错误

4、show variables like ‘%log_bin%’ 查看开启

+---------------------------------+--------------------------------------+
| Variable_name                   | Value                                |
+---------------------------------+--------------------------------------+
| log_bin                         | ON                                   |
| log_bin_basename                | /usr/local/var/mysql/mysql-bin       |
| log_bin_index                   | /usr/local/var/mysql/mysql-bin.index |
| log_bin_trust_function_creators | OFF                                  |
| log_bin_use_v1_row_events       | OFF                                  |
| sql_log_bin                     | ON                                   |
+---------------------------------+--------------------------------------+

5、查看binlog日志状态

show master status 

6、刷新binlog日志文件

flush logs #刷新之后会新建一个新的Binlog日志

7、清空日志文件

reset master

8、查看binlog日志文件

mysqlbinlog mysql-bin.000002

你可能感兴趣的:(MySQL,mysql-binlog)