mysql主从配置
主
mysql -uroot -p'd60v#-MXf>qn'
create database ywgl;
grant replication slave,replication client on *.* to 'repl'@'192.168.100.125' identified by 'd60v#-MXf>qn';
mysql> flush privileges;
mysql> use mysql;
mysql> show tables;
mysql> select * from user\G
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000004 | 1255618 | | | |
+------------------+----------+--------------+------------------+-------------------+
从
mysql> mysql -uroot -p'Fghj7S0Cl#ef'
mysql> create database ywgl;
mysql> show global variables like '%relay%';
mysql> stop slave;
mysql> change master to master_host='172.16.4.41',master_user='repl',master_password='d60v#-MXf>qn',master_port=3306,master_log_file='mysql-bin.000004',master_log_pos=1255618;
mysql> set global read_only=1;
mysql> flush privileges;
mysql> start slave;
mysql> show slave status\G
# 主从报错的话,比如是Got fatal error 1236 可以在主上执行刷新日志操作
mysql> flush logs;