CentOS-7 MySQL5.7.31 配置主从复制
时间:2021-07-01 10:21:17
帮助过:10人阅读
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.31-log MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
mysql>
grant replication slave on *.* to ‘cpp‘@‘%‘ identified by ‘123.com‘;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
# 服务id
server-id = 2
# 开启mysql 启动中继日志
relay-log=relay-log
修改完后重启MySQL
登录从数据库,配置主从
在从库上指定主库地址,以及 同步账号、密码,并启动同步
mysql>
mysql>
mysql> change master to master_host=‘192.168.137.128‘,master_user=‘cpp‘,master_password=‘123.com‘;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
show slave status\G; 查看从库状态,查看Slave_IO_Running: Yes和 Slave_SQL_Running: Yes 为yes主从配置完成
如果启动同步后,第一个为Connecting,第二个为Yes,大部分为连接问题,请检查网络是否通,配置的用户名密码是否正确
CentOS-7 MySQL5.7.31 配置主从复制
标签:bin 检查网络 两台 复制 更改 row 一个 with 地址