天天看點

mysql 不同步

show slave status

slave stop

CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000024',MASTER_LOG_POS=107;

slave start;

show processlist; 

flush tables with read lock;

show master status;   -> // CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000024',MASTER_LOG_POS=107;

flush logs;

--------------------------------------------------------------------------------------------------------------------------------------------------

本來配置可以使用的​​mysql​​主從庫同步的資料庫,突然出現無法同步的情況。那麼大家可以參考下面的方法解決下。

遇到這樣的錯誤如:“Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'”等或由于清資料導緻主從庫不同步了,解決辦法如下: 

先進入slave中執行:"slave stop;"來停止從庫同步; 

再去master中執行:"flush logs;"來清空日志; 

然後在master中執行:"show master status;"檢視下主庫的狀态,主要是日志的檔案和position; 

然後回到slave中,執行:"CHANGE MASTER TO MASTER_LOG_FILE='log-bin.000004',MASTER_LOG_POS=106;",檔案和位置對應master中的; 

最後在slave中執行:"slave start;"來啟動同步。

REPAIR TABLE `table_name` 修複表 

OPTIMIZE TABLE `table_name` 優化表 

UNLOCK TABLES 全部解鎖