1. 程式人生 > >mac下MYSQL5.7.20開啟binlog日誌

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