Mysql - Mysql Master error :Failed to initialize the master info structure

遷移來(lái)自51cto博客


今天在配置mysql replication的時(shí)候,修改完my.cnf文件,然后重啟mysql service ,當(dāng)執(zhí)行下列命名的時(shí)候報(bào)錯(cuò):


change master to master_host='127.0.0.1',
master_user='usertest',master_password='usertest', master_log_file='mysql-bin-000002', master_log_pos=8;

ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log


check錯(cuò)誤日志文件 mysqld.log ,發(fā)現(xiàn)有如下錯(cuò)誤:

140123 12:48:18 [ERROR] Error reading master configuration
140123 12:48:18 [ERROR] Failed to initialize the master info structure

后來(lái)檢查發(fā)現(xiàn)在mysql數(shù)據(jù)庫(kù)文件夾下面有個(gè) 空的master.info 文件(有時(shí)候還有個(gè)空的relay-log.info),問(wèn)題在這里。

解決辦法:
method 1 :

mysql> stop slave ;
mysql> reset salve ;
then change master
mysql> change master to master_host='127.0.0.1', master_user='usertest', master_pass  
word='usertest', master_log_file='mysql-bin-000002', master_log_pos=8;  
Query OK, 0 rows affected (0.11 sec)  

method 2 :

rm -f /var/lib/mysql/master.info
then
mysql> change master to master_host='127.0.0.1', master_user='usertest', master_pass  
word='usertest', master_log_file='mysql-bin-000002', master_log_pos=12;  
Query OK, 0 rows affected (0.11 sec)  

最后檢查MySQL主從同步是否正常

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: 127.0.0.1
                 Master_User: korea_slave
                 Master_Port: 3306
               Connect_Retry: 60
             Master_Log_File: bin-update-log.000009
         Read_Master_Log_Pos: 1551
              Relay_Log_File: mysqld-relay-bin.000002
               Relay_Log_Pos: 1702
       Relay_Master_Log_File: bin-update-log.000009
            Slave_IO_Running: Yes
           Slave_SQL_Running: Yes
             Replicate_Do_DB: tkglobal,tktest
         Replicate_Ignore_DB: local
          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: 1551
             Relay_Log_Space: 1859
             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: 0
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: 1260119
1 row in set (0.00 sec)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • ·錯(cuò)誤:1000 SQLSTATE: HY000 (ER_HASHCHK)消息:hashchk·錯(cuò)誤:1001 S...
    Catke閱讀 1,714評(píng)論 0 2
  • 前言: 其實(shí)也不知道要寫(xiě)點(diǎn)什么前言,聽(tīng)朋友說(shuō)前言就是交代你為什么要來(lái)寫(xiě)這個(gè)。那么我之所以寫(xiě)這個(gè)其實(shí)也很簡(jiǎn)單啦,作為...
    笑笑姐姐HHH閱讀 308評(píng)論 0 0
  • 你是否已走得太遠(yuǎn),以至于忘了為什么出發(fā)? 每個(gè)人都擁有自己的初心,它是出生時(shí)的第一聲啼哭,是戀愛(ài)時(shí)的第一次萌動(dòng),是...
    AZander閱讀 102評(píng)論 0 0
  • 東坡肘子紅粉肉,青天問(wèn)月水東流。 心系宋家民生茍,學(xué)士盡瘁百轉(zhuǎn)憂。
    一一無(wú)痕閱讀 286評(píng)論 27 16
  • 文丨南瓜咚 如果硬要說(shuō)我還青春著,那大概是后青春時(shí)代吧,畢竟二十好幾的人,如果說(shuō)我還正青春年少,臉上還是掛不住的,...
    南瓜咚閱讀 576評(píng)論 0 1

友情鏈接更多精彩內(nèi)容