JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 数据库 » 删除mysql同步信息,干净的清除Slave同步信息

删除mysql同步信息,干净的清除Slave同步信息

此文被围观3316日期: 2013-05-16 分类 : 数据库  标签:  ······
在做mysql主从同步的时候设置了本机为从数据库,但是后来又想删除这个从的同步数据。 下面是网上找到的方法,测试过了可行! 如何干净的清除Slave同步信息【小技巧】  1. mysql> show slave statusG;   2. *************************** 1. row ***************************   3.                Slave_IO_State: Waiting for master to send event   4.                   Master_Host: 192.168.8.22   5.                   Master_User: repl   6.                   Master_Port: 3306   7.                 Connect_Retry: 10   8.               Master_Log_File: mysql-bin.000015   9.           Read_Master_Log_Pos: 107   10.                Relay_Log_File: vm02-relay-bin.000025   11.                 Relay_Log_Pos: 253   12.         Relay_Master_Log_File: mysql-bin.000015  13.              Slave_IO_Running: Yes   14.             Slave_SQL_Running: Yes   15.               Replicate_Do_DB:    16.           Replicate_Ignore_DB:    17.            Replicate_Do_Table:    18.        Replicate_Ignore_Table:    19.       Replicate_Wild_Do_Table:    20.   Replicate_Wild_Ignore_Table:    21.                    Last_Errno: 0   22.                    Last_Error:    23.                  Skip_Counter: 0   24.           Exec_Master_Log_Pos: 107   25.               Relay_Log_Space: 554   26.               Until_Condition: None   27.                Until_Log_File:    28.                 Until_Log_Pos: 0   29.            Master_SSL_Allowed: No   30.            Master_SSL_CA_File:    31.            Master_SSL_CA_Path:    32.               Master_SSL_Cert:    33.             Master_SSL_Cipher:    34.                Master_SSL_Key:    35.         Seconds_Behind_Master: 0   36. Master_SSL_Verify_Server_Cert: No   37.                 Last_IO_Errno: 0   38.                 Last_IO_Error:    39.                Last_SQL_Errno: 0   40.                Last_SQL_Error:    41.   Replicate_Ignore_Server_Ids:    42.              Master_Server_Id: 22   43. 1 row in set (0.03 sec)  44.    45.  ERROR:    46. No query specified   现在由于业务的需要,不需要这台Slave同步复制Master,那么采用reset slave时,你会发现同步信息还存在,如: 1. mysql> stop slave;   2. Query OK, 0 rows affected (0.19 sec)  3.    4. mysql> reset slave;   5. Query OK, 0 rows affected (0.17 sec)  6.    7. mysql> show slave statusG;   8. *************************** 1. row ***************************  9.                Slave_IO_State:    10.                   Master_Host: 192.168.8.22   11.                   Master_User: repl   12.                   Master_Port: 3306   13.                 Connect_Retry: 10   14.               Master_Log_File:    15.           Read_Master_Log_Pos: 4   16.                Relay_Log_File: vm02-relay-bin.000001   17.                 Relay_Log_Pos: 4   18.         Relay_Master_Log_File:    19.              Slave_IO_Running: No   20.             Slave_SQL_Running: No   21.               Replicate_Do_DB:    22.           Replicate_Ignore_DB:    23.            Replicate_Do_Table:    24.        Replicate_Ignore_Table:    25.       Replicate_Wild_Do_Table:    26.   Replicate_Wild_Ignore_Table:    27.                    Last_Errno: 0   28.                    Last_Error:   2 9.                  Skip_Counter: 0   30.           Exec_Master_Log_Pos: 0   31.               Relay_Log_Space: 126   32.               Until_Condition: None   33.                Until_Log_File:    34.                 Until_Log_Pos: 0   35.            Master_SSL_Allowed: No   36.            Master_SSL_CA_File:    37.            Master_SSL_CA_Path:    38.               Master_SSL_Cert:    39.             Master_SSL_Cipher:    40.                Master_SSL_Key:    41.         Seconds_Behind_Master: NULL   42. Master_SSL_Verify_Server_Cert: No   43.                 Last_IO_Errno: 0   44.                 Last_IO_Error:    45.                 Last_SQL_Errno: 0   46.                Last_SQL_Error:    47.   Replicate_Ignore_Server_Ids:    48.              Master_Server_Id: 22   49. 1 row in set (0.02 sec)   50.    51. ERROR:    52. No query specified   执行reset slave,其实是把master.info和relay-log.info文件给删除,但里面的同步信息还在,那么可以用这个方法,让其清除的彻彻底底。 1. mysql> reset slave all;   2. Query OK, 0 rows affected (0.04 sec)  3.    4. mysql> show slave statusG;  5. Empty set (0.02 sec)  6.    7. ERROR:    8. No query specified       注:此语句支持在MySQL5.5或更高版本。

站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号