log-bin=/var/lib/mysql/mysql-bin server-id=1
重启 MySQL 服务 :
service mysqld stop service mysqld start ## 如果出错查看日志 3 vi /var/log/mysqld.log cd /var/lib/mysql
是否开启
binlog show variables like ‘log_bin%‘;
show global variables like ‘%binlog_format%‘;
show binary logs;
show binlog events in ‘mysql-bin.000001‘;
用mysqlbinlog工具,基于时间查看binlog:
/usr/bin/mysqlbinlog --start-datetime=‘2019-08-2213:30:00‘ --stop-datetime=‘2019-08-2214:01:01‘-d test /var/lib/mysql/mysql-bin.000001
4. 主从复制原理
1、主库开启 binlog,设置 server-id
2、在主库创建具有复制权限的用户,允许从库连接
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO ‘repl‘@‘192.168.8.147‘ IDENTIFIED BY ‘123456‘;
FLUSH PRIVILEGES;
server-id=2
log-bin=mysql-bin
relay-log=mysql-relay-bin
read-only=1
log-slave-updates=1
stop slave;
change master to
master_host=‘192.168.8.146‘,master_user=‘repl‘,master_password=‘123456‘,master_log_file=‘mysql-bin.000001‘,
master_log_pos=4;
start slave;
SHOW SLAVE STATUS \G
原文:https://www.cnblogs.com/47Gamer/p/13686455.html