时间:2021-07-01 10:21:17 帮助过:26人阅读
yum install mysql mysql-server mysql-devel vim /etc/my.cnf server-id = 1 log-bin=mysql-bin binlog_format = mixed binlog-ignore-db = mysql binlog-ignore-db = test binlog-ignore-db = information_schema service mysqld start mysql> grant replication slave on *.* to‘repl‘@‘%‘ identified by ‘123456‘; mysql> show master status\G;
记录当前二进制日志文件以及位置
File: mysql-bin.000001 Position: 239
slave端:
yum install mysql mysql-server mysql-devel vim /etc/my.cnf server-id = 2 service mysqld start mysql>change master tomaster_host=‘192.168.1.240‘, master_user=‘repl‘, master_password=‘123456‘, mater_port=‘3306‘, master_log_file=‘mysql-bin.000001‘, master_log_pos=239; mysql> start slave; mysql> show slave status\G; Slave_IO_Running: Yes Slave_SQL_Running: Yes
至此,在master(主库)端进行增删改等操作会同步到slave(从库)
本文出自 “linux_cheng” 博客,请务必保留此出处http://6764097.blog.51cto.com/6754097/1827346
mysql主从同步
标签:service 二进制 status