MySQL master-slave data is inconsistent, prompt: Slave_SQL_Running: No solution

MySQL master-slave data is inconsistent, prompt: Slave_SQL_Running: No solution

This article uses an example to describe the solution to the inconsistency between MySQL master and slave data, and the prompt: Slave_SQL_Running No. Share with you for your reference, the details are as follows:

On the slave server, run the following command

mysql> show slave status\G;

The following is displayed:

Slave_IO_Running: Yes
Slave_SQL_Running: No

Indicates that the slave is out of sync

Solution 1 (ignore the error and continue syncing):

1. Stop the slave first

mysql> stop slave;

2. Skip the wrong steps, and the following steps can be changed

mysql> set global sql_slave_skip_counter=1;

3. Restart slave

mysql> start slave;

4. Check the synchronization status

mysql> show slave status\G;

Solution 2 (re-do master-slave, complete synchronization):

1. Enter the main database first to lock the table, and be careful not to close the window

mysql> flush table with read lock;

2. Back up your data

> mysqldump -uroot -p --opt -R database > /data/bak.sql

3. Open a new window to view the main database information

mysql> show master status;

+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000005 | 1158 | | | |
+------------------+----------+--------------+------------------+-------------------+

4. Stop slave on the slave library

mysql> stop slave;

5. Import the backup data file

mysql> source /data/bak.sql

6. Reset Sync

mysql> reset slave;

7. Reset the synchronization node

mysql> CHANGE MASTER TO
MASTER_HOST='192.168.137.233',
MASTER_PORT=3306,
MASTER_USER='sync',
MASTER_PASSWORD = '123456',
MASTER_LOG_FILE='mysql-bin.000005',
MASTER_LOG_POS=1158;

Please modify host, port, user, and password according to your master database settings, and modify log_file and log_pos according to the master status in the master database.

8. Enable slave

mysql> start slave;

9. Check slave status

mysql> show slave status\G;

If the following information is displayed, it is normal

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

10. Unlock the master database

mysql> unlock tables;

11. Add or modify data in the master database again to see whether the slave database data is synchronized.

Readers who are interested in more MySQL-related content can check out the following topics on this site: "MySQL query skills", "MySQL common functions summary", "MySQL log operation skills", "MySQL transaction operation skills summary", "MySQL stored procedure skills" and "MySQL database lock related skills summary"

I hope this article will be helpful to everyone's MySQL database design.

You may also be interested in:
  • Optimization method for mysql synchronization problem of large slave delay
  • Basic tutorial on solving slave latency issues in MySQL
  • Analysis of delays in slave monitoring in MySQL
  • A practical record of restoring a MySQL Slave library
  • Mysql master/slave database synchronization configuration and common errors
  • Detailed explanation of slave_exec_mode parameter in MySQL
  • MySQL5.6 database master-slave synchronization installation and configuration details (Master/Slave)
  • Solution to MySQL Slave triggering oom-killer
  • MySQL slave delays foreign key check and auto-increment lock for a column

<<:  Echarts Bar horizontal bar chart example code

>>:  How to install docker on ubuntu20.04 LTS

Recommend

Vue implements a simple shopping cart example

This article example shares the specific code of ...

vue-router hook function implements routing guard

Table of contents Overview Global hook function R...

Analysis of the principle and usage of MySQL custom functions

This article uses examples to illustrate the prin...

The basic use of html includes links, style sheets, span and div, etc.

1. Links Hypertext links are very important in HTM...

Mysql master-slave synchronization Last_IO_Errno:1236 error solution

What is the reason for the Last_IO_Errno:1236 err...

JS, CSS style reference writing

CSS: 1. <link type="text/css" href=&q...

What do CN2, GIA, CIA, BGP and IPLC mean?

What is CN2 line? CN2 stands for China Telecom Ne...

Comprehensive understanding of line-height and vertical-align

Previous words Line-height, font-size, and vertica...

Summary of special processing statements of MySQL SQL statements (must read)

1. Update the entire table. If the value of a col...

Guide to Efficient Use of MySQL Indexes

Preface I believe most people have used MySQL and...

Comprehensive summary of MYSQL tables

Table of contents 1. Create a table 1.1. Basic sy...

MySQL MyISAM default storage engine implementation principle

By default, the MyISAM table will generate three ...

How to use anti-shake and throttling in Vue

Table of contents Preface concept Stabilization d...

A brief introduction to MySQL InnoDB ReplicaSet

Table of contents 01 Introduction to InnoDB Repli...

Several ways to backup MySql database

mysqldump tool backup Back up the entire database...