mysql error 1146

Solutions on MaxInterview for mysql error 1146 by the best coders in the world

showing results for - "mysql error 1146"
Veronica
04 Jul 2017
1#To fix the replication error follow the steps below.
2
3#1. First, we log into the MYSQL.
4
5mysql -u root -p
6 
7#2. On the MySQL shell, we check the slave status.
8
9mysql> SHOW SLAVE STATUS
10
11#The sample result as follows.
12
13mysql> SHOW SLAVE STATUS
14*************************** 1. row ***************************
15Slave_IO_State: Waiting for master to send event
16Master_Host: 1.2.3.4
17Master_User: slave_user
18Master_Port: 3306
19Connect_Retry: 60
20Master_Log_File: mysql-bin.001089
21Read_Master_Log_Pos: 269214467
22Relay_Log_File: slave-relay.000234
23Relay_Log_Pos: 100125935
24Relay_Master_Log_File: mysql-bin.001079
25Slave_IO_Running: Yes
26Slave_SQL_Running: No
27Replicate_Do_DB: mydb
28Last_Errno: 1146
29 
30#If anyone of the Slave_IO_Running or Slave_SQL_Running is set as NO, it means the replication is broken.
31#So, we start to repair the MYSQL replication.
32
33#3. For that, we stop the slave from replication, using the below command.
34
35mysql> STOP SLAVE;
36
37#4. Next, we tell the slave to simply skip the invalid SQL query. So we use the below command.
38
39mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
40
41#This query tells the slave to skip one query (which is the invalid one that caused the replication to stop).  If we like to skip two queries, we use the following code instead.
42
43SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 2;
44#That’s it.
45
46#5. Again, we start the slave.
47
48mysql> START SLAVE;
49
50#6. After that, we check if replication is working again.
51
52mysql> SHOW SLAVE STATUS
53
54mysql> SHOW SLAVE STATUS
55*************************** 1. row ***************************
56Slave_IO_State: Waiting for master to send event
57Master_Host: 1.2.3.4
58Master_User: slave_user
59Master_Port: 3306
60Connect_Retry: 60
61Master_Log_File: mysql-bin.001089
62Read_Master_Log_Pos: 269214467
63Relay_Log_File: slave-relay.000234
64Relay_Log_Pos: 100125935
65Relay_Master_Log_File: mysql-bin.001079
66Slave_IO_Running: Yes
67Slave_SQL_Running: Yes
68Replicate_Do_DB: mydb
69Last_Errno: 1146 
70
71#Both Slave_IO_Running and Slave_SQL_Running are set to Yes now. And the replication is running without any error.
72#Then we leave the MySQL shell.
73
74mysql> quit;