Home > Database > Mysql Tutorial > body text

两主机搭建MySQL主从复制后,show slave status显示:Last_IO_Er_MySQL

WBOY
Release: 2016-06-01 13:28:55
Original
1268 people have browsed it

bitsCN.com

两主机搭建MySQL主从复制后,show slave status显示:Last_IO_Error: error connecting to master ……解决

 

两台主机A、B搭建mysql主从复制关系(A为master,B为slave)后,在slave上执行show slave status,结果中显示Last_IO_Error: error connecting to master 'replication@VMS00782:3306'……

 

首先查看B的错误日志文件,发现如下错误:

 

ERROR] Slave I/O: error connecting to master 'replication@VMS00782:3306' - retry-time: 60  retries: 2, Error_code: 1045

 

接着用perror查看上一部获得的错误代码:

 

perror 1045

 

输出:

MySQL error code 1045 (ER_ACCESS_DENIED_ERROR): Access denied for user '%-.48s'@'%-.64s' (using password: %s)
Copy after login

难道是复制用的账户存在问题??先在A上确认复制用户账户是否存在且是否赋了正确的权限

 mysql> show grants for 'usvr_replication'@'%';+-----------------------------------------------------------------------------------------------------------------------------+| Grants for usvr_replication@%                                                                                               |+-----------------------------------------------------------------------------------------------------------------------------+| GRANT REPLICATION SLAVE ON *.* TO 'usvr_replication'@'%' IDENTIFIED BY PASSWORD '*F4039654D0AFD80BB0A7775938EFD47ACB809529' |+-----------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)
Copy after login

发现没有问题!

然后,试着从B使用该账户连接至A:

mysql -uusvr_replication -h 192.168.83.35 -p -P55944
Copy after login

输入设置的密码后回车,没连上!!!再次输入,还没连上!!!

看来问题出在这儿了,仔细检查,原来是密码记错了!

试着用正确的密码重建复制关系:

在B上执行:

mysql>stop slave;mysql>researt slave;mysql>change master to master_host = 'VMS00782',master_user = 'replication',master_password = 'ReplPass@123456',master_port = 3306,master_log_file = 'VMS00782-bin.000001',master_log_pos = 120;mysql>start slave;mysql>show slave status;
Copy after login

 

 

一切正常!!!

 

需要注意的几个问题:

 

要在change master to语句的master_password部分使用原始的密码而非散列过的密码。

 

注意在第一时间查看错误日志文件,可使用perror工具根据错误代码查看具体的错误。

 

另外几个常见问题:

 

mysql无法启动:先看错误日志文件中提示的错误,依据错误找原因;查看配置文件中数据目录等配置是否正确;检查MySQL相关目录属主和属组是否正确;查看是否有之前未被正确关闭的mysqld进程仍在运行。

 

mysql无法连接:先看mysqld进程是否正确启动了;再看提供的连接串是否争取无误。

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template