mysql从库切换到主库
---------------------MySQL主从切换------------------
1.停止从服务器slave服务:
mysql> stop slave
2.将从服务器切换为主服务器,在从服务器上执行
mysql> reset master
mysql> reset slave all;
注:reset slave all 命令会删除从库的 replication 参数,之后 show slave status\G 的信息返回为空
3.查看当前从服务器变更为主服务器的binlog信息,若是现在没有写入的话,可以把原来的主库变成从库
mysql> show master status\G;
*************************** 1. row ***************************
File: binlog.000001
Position: 154
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
ERROR:
No query specified
4.将read_only关闭
show variables like '%read_only%';
set global read_only=off;
同时写入到配置文件中,重启后生效
浙公网安备 33010602011771号