本篇內容主要講解“報錯Error_code: 1045的解決方法”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強。下面就讓小編來(lái)帶大家學(xué)習“MySQL報錯Error_code: 1045的解決方法”吧!
今天把兩臺機器恢復主從關(guān)系后,在slave上執行show slave status,結果中顯示
2017-04-21T13:46:15.133435Z 8806 [ERROR] Slave I/O for channel '': error connecting to master 'repl@192.168.2.40:3306' - retry-time: 60 retries: 1, Error_code: 1045
首先查看slave的錯誤日志文件,和上面的錯誤一樣
接著(zhù)用perror查看上一部獲得的錯誤代碼:
[root@iZ2ze5ifr62amhrpcnpn9yZ mysql]# perror 1045
MySQL error code 1045 (ER_ACCESS_DENIED_ERROR): Access denied for user '%-.48s'@'%-.64s' (using password: %s)
有可能是復制用的賬戶(hù)存在問(wèn)題,先在MASTER上確認復制用戶(hù)賬戶(hù)是否存在且是否賦了正確的權限
mysql> show grants for repl@192.168.2.41;
+---------------------------------------------------------+
| Grants for repl@192.168.2.41 |
+---------------------------------------------------------+
| GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.2.41' |
+---------------------------------------------------------+
1 row in set (0.00 sec)
發(fā)現沒(méi)有問(wèn)題,試著(zhù)從master使用該賬戶(hù)連接至slave,果然沒(méi)連上
[root@iZ2ze5ifr62amhrpcnpn9yZ ~]# mysql -urepl -h 192.168.2.40 -p -P3306
Enter password:
ERROR 1045 (28000): Access denied for user 'repl'@'192.168.2.40' (using password: YES)
之前的密碼可能不對,修改一個(gè)新的密碼
mysql> update mysql.user set authentication_string=PASSWORD('REPLsafe!@#$41') where User='repl' and host='192.168.2.41';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
試著(zhù)用新的密碼重建復制關(guān)系,問(wèn)題解決。
mysql> stop slave;
Query OK, 0 rows affected (0.01 sec)
mysql> change master to
-> master_host='192.168.2.40',
-> master_port=3306,
-> master_user='repl',
-> master_password='REPLsafe!@#$41',
-> master_log_file='bin.000043',
-> master_log_pos=799072709;
Query OK, 0 rows affected, 2 warnings (0.05 sec)
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.2.40
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin.000043
Read_Master_Log_Pos: 854716379
Relay_Log_File: relay.000002
Relay_Log_Pos: 1135224
Relay_Master_Log_File: bin.000043
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: cus_DEMO,cus_DEMO_0413,cus_DEMO_0414,cus_DEMO_0418
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: 800207619
Relay_Log_Space: 55644221
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: 18559
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 40
Master_UUID: 1b00b716-cf6a-11e6-b66e-00163e320583
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: System lock
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 1b00b716-cf6a-11e6-b66e-00163e320583:34573831-34680957
Executed_Gtid_Set: 1b00b716-cf6a-11e6-b66e-00163e320583:1-33612321:34573831-34620341
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站