In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to switch between master and slave in MySQL database? for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
1. View the status of the main library show processlist; Master has sent all binlog to slave; waiting for binlog to be updated show master status\ G
2. View the slave library status show processlist; show slave status\ G
3. Stop the IO_THREAD thread stop slave IO_THREAD; show processlist; show slave status\ G from the library
4. Switch from library to main library stop slave; reset master; reset slave all; show master status\ G
5. Activate the account SELECT DISTINCT CONCAT ('User:'', user,'''@''',host,''';') AS query FROM mysql.user; GRANT REPLICATION SLAVE ON *. * TO 'repl'@'%' IDENTIFIED BY' xxx; FLUSH PRIVILEGES
6. Switch the original master database to slave database (executed by the original master database) reset master; reset slave all; CHANGE MASTER TO MASTER_HOST='1xxx', MASTER_USER='repl', MASTER_PASSWORD='xxx, MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=589
7. Check the main library SHOW PROCESSLIST; show master status\ G
8. Start the slave SHOW PROCESSLIST; start slave; show slave status\ G
9. MySQL Master-Slave Test 9.1 insert data 9.1.1 create test table and insert data mysql > create table test123 (id int (4)); Query OK, 0 rows affected (0.01 sec) mysql > insert into test123 values (1); Query OK, 1 row affected (0.00 sec) mysql > insert into test123 values (2); Query OK, 1 row affected (0.00 sec) mysql > insert into test123 values (3); Query OK, 1 row affected (0.00 sec) mysql > insert into test123 values (4) Query OK, 1 row affected (0.00 sec)
9.1.2 query from the library:
9.2 delete data 9.2.1 main library delete table: mysql > drop table test123
9.2.2 query from the library: this is the answer to the question about how to switch between master and slave in the MySQL database. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.