mysql主从同步配置好之后,数据没有同步,从数据库出现如下错误
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: 192.168.3.27
Master_User: backup
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: localhost-relay-bin.000003
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: No Slave_SQL_Running: Yes
Replicate_Do_DB: redmine
Replicate_Ignore_DB: mysql
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 0
Relay_Log_Space: 106
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 1045
Last_IO_Error: error connecting to master 'backup@192.168.3.27:3306' - retry-time: 60 retries: 86400 Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
ERROR:
No query specified
连接主数据库出错,但直接连接又是OK的
/usr/local/mysql/bin/mysql -ubackup -p123 -h 192.168.3.27
Slave_IO_Running: No
出现这个情况,有两种可能:
1、权限的设置问题,slave没有权限访问master
2、同步过程中出错
已经设置了权限了,可以排除第一点
grant replication slave on *.* to backup@192.168.3.25 identified by '123';
解决方法:
从服务器上删除掉所有的二进制日志文件,包括一个数据目录下的master.info文件和hostname-relay-bin开头的文件
master.info::记录了Mysql主服务器上的日志文件和记录位置、连接的密码
删除之后,重启数据库,ok