错误详情
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.11.159.138
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 91238
Relay_Log_File: mysql-relay-bin.000006
Relay_Log_Pos: 612
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: dataxweb
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1064
Last_Error: Error 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'password'' at line 1' on query. Default database: ''. Query: 'grant replication slave on *.* to 'root'@'10.11.159.91' identified by 'password''
Skip_Counter: 0
Exec_Master_Log_Pos: 413
Relay_Log_Space: 91693
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: 0
Last_IO_Error:
Last_SQL_Errno: 1064
Last_SQL_Error: Error 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'password'' at line 1' on query. Default database: ''. Query: 'grant replication slave on *.* to 'root'@'10.11.159.91' identified by 'password''
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID:
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 200915 19:36:44
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
Master_public_key_path:
Get_master_public_key: 0
Network_Namespace:
1 row in set (0.00 sec)
错误原因
mysql做主从的过程中,由于主库中执行了grant replication slave on *.* to 'root'@'<slave_ip>' identified by 'password'
赋权操作,而主库写入了binlog。从库拿到binlog之后,也执行了这句,从库是不可以执行grant replication slave
,所以导致的报错。
解决办法
跳过这条错误
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL sql_slave_skip_counter=1;
Query OK, 0 rows affected (0.00 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
这就像抄作业,从库只顾着“抄作业”,而不管是不是正确的,导致了这个错误。
遇到错误不要着急,冷静分析。