mysql8 主从复制和主主复制
作者:互联网
- 主从复制:
主服务器
create user 'masteruser'@'192.168.68.13' identified WITH 'mysql_native_password' by 'xxx';
grant all privileges on *.* to 'masteruser'@'192.168.68.13' with grant option;
FLUSH PRIVILEGES;
show master status;
从服务器
CHANGE MASTER TO MASTER_HOST='192.168.68.12', MASTER_USER='masteruser', MASTER_PASSWORD='xxx', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=155;
start slave;
show slave status\G;
- 主主复制
主服务器配置
auto_increment_increment=2
auto_increment_offset=1
从服务器配置
auto_increment_increment=2
auto_increment_offset=2
重启mysqld
从服务器
create user 'masteruser13'@'192.168.68.12' identified WITH 'mysql_native_password' by 'xxx';
grant all privileges on *.* to 'masteruser13'@'192.168.68.12' with grant option;
FLUSH PRIVILEGES;
show master status;
主服务器
CHANGE MASTER TO MASTER_HOST='192.168.68.13', MASTER_USER='masteruser13', MASTER_PASSWORD='xxx', MASTER_LOG_FILE='mysql-bin.000006', MASTER_LOG_POS=155;
start slave
show slave status
- 命令参考
stop slave 停止
reset slave all 删除
flush tables with read lock 锁表
unlock tables 接触锁表
show processlist 查看连接
标签:主从复制,slave,show,mysql8,192.168,主主,MASTER,increment,服务器 来源: https://blog.csdn.net/qq_32319891/article/details/98595024