1. 程式人生 > >MySQL錯誤處理--1146錯誤

MySQL錯誤處理--1146錯誤

在MySQL的主從複製過程中,出現了1146錯誤。提示的錯誤原因是:在預設的資料中找不到指定的表。
show slave status\G;現實的同步狀態。
Slave_IO_Running: YES
Slave_SQL_Running: No
Last_Errno: 1146
Last_Error: Error 'Table 'coop.Coop_Data' doesn't exist' on query. Default database: 'gcore'. Query: 'update coop.Coop_Data set State='2',NameLevel='2',CheckedTime=now(),Memo='' where DAID='18601''
Skip_Counter: 0
Last_SQL_Errno: 1146
Last_SQL_Error: Error 'Table 'coop.Coop_Data' doesn't exist' on query. Default database: 'gcore'. Query: 'update coop.Coop_Data set State='2',NameLevel='2',CheckedTime=now(),Memo='' where DAID='18601''

原因是:
先使用的use db_name1,然後執行了 update db_name2.table set這種sql語句。

解決方法:
在從伺服器上設定忽略該錯,在my.cnf檔案中新增“slave-skip-errors = 1146”,
如果少量的這種錯誤,直接在mysql client裡面設定“set global sql_slave_skip_counter=1”;