MySQL master-slave data inconsistency Slave_sql_running:no solution

Source: Internet
Author: User

On the slave server, use the following command

Mysql> show Slave status\g;

The following conditions are displayed:

Slave_IO_Running:YesSlave_SQL_Running:No

Indicates that slave is out of sync

Workaround One (ignore the error, continue syncing):

1, first stop slave

mysql> stop Slave;

2, skip the wrong steps, the number of steps after the variable

3. Re-start slave

mysql> start slave;

4. View sync Status

Mysql> show Slave status\g;

  

Workaround two (re-master from, fully synchronized):

1, the Advanced Master Library to lock the table, note that the window does not close

Mysql> Flush table with read lock;

2. Backup the 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 from the library

mysql> stop Slave;

5. Import the backed up data file

Mysql> Source/data/bak.sql

6. Reset Sync

mysql> Reset Slave;

7. Reset the Sync node

mysql> change MASTER tomaster_host= ' 192.168.137.233 ', master_port=3306,master_user= ' sync ', master_password= ' 123456 ', master_log_file= ' mysql-bin.000005 ', master_log_pos=1158;

Host,port,user,password Please modify the settings according to your main library, log_file and Log_pos are modified according to the master status in the main library.

8. Open Slave

mysql> start slave;

9. View slave status

Mysql> show Slave status\g;

Displaying the following information indicates normal

Slave_IO_Running:YesSlave_SQL_Running:Yes

10. Unlocking the primary database

mysql> unlock tables;

11. Add or modify data in the main library again to see if the data is synchronized from the library.

MySQL master-slave data inconsistency Slave_sql_running:no solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.