【mysql主从复制】master里添加从机ip后从机就不能连接
本帖最后由 thepoy 于 2019-7-18 12:41 编辑主机给从机添加授权:
GRANT REPLICATION SLAVE ON *.* TO 'user01'@'192.168.226.129' IDENTIFIED BY '123456';
刷新后:
show master status;
+-----------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-----------------+----------+--------------+------------------+
| mysqlbin.000004 | 858 | | mysql |
+-----------------+----------+--------------+------------------+
主机的二进制文件和serverid均已设置。
从机改slave:
CHANGE MASTER TO MASTER_HOST='192.168.0.104',
MASTER_USER='user01',
MASTER_PASSWORD='123456',
MASTER_LOG_FILE='mysqlbin.000004',MASTER_LOG_POS=858;
这样就报错了:
show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
省略n行
Last_IO_Error: error connecting to master 'user01@192.168.0.104:3306' - retry-time: 60maximum-retries: 86400message: Access denied for user 'user01'@'192.168.0.104' (using password: YES)
1 row in set (0.000 sec)
密码没错和pos正确,但无法连接。
然后想着添加一个账户,把把主机的授权ip变为任意ip:
GRANT REPLICATION SLAVE ON *.* TO 'user03'@'%' IDENTIFIED BY '123456';
把file和pos的更新写入slave后成功:
show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.104
Master_User: user03
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqlbin.000004
Read_Master_Log_Pos: 858
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 554
Relay_Master_Log_File: mysqlbin.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
同一个网络环境下,用的都是内网ip,主机和从机的ip能互相ping能,为什么会报这种错呢?
本帖最后由 Laotu 于 2019-7-18 11:17 编辑
用从运行
mysql -h192.168.226.129 -uuse01 -p
输入密码看看是否能够登陆成功
从用mysql命令登陆主,查看是否能够成功登陆,如果不能登陆
给use01添加master权限
同一个局域网,直接root账号搞就行了。 Laotu 发表于 2019-7-18 11:15
用从运行
输入密码看看是否能 ...
GRANT ALL PRIVILEGES ON *.* TO 'user01'@'192.168.226.129' IDENTIFIED BY '123456';
还是报错 Last_IO_Errno: 1045
。。。。。。。。。。。。
我这是在学习主从复制啊,所以才ip登陆
页:
[1]