🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
数据库版本:MySQL 5.6.27 操作系统 :CentOS 7.4 Linux环境下MySQL的配置文件的位置是在 /etc/my.cnf Master的配置如下: ~~~ log-bin=mysql-bin server-id=1 :用于标识唯一的数据库 binlog-ignore-db=information_schema binlog-ignore-db=performance_schema binlog-ignore-db=sys binlog-ignore-db=mysql binlog-do-db=yzdd binlog-ignore-db:表示同步的时候忽略的数据库 binlog-do-db:指定需要同步的数据库 ~~~ 然后重启mysql:service mysqld restart 指定从属账号 GRANT REPLICATION SLAVE ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456'; >FLUSH PRIVILEGES; Slave的配置 log-bin=mysql-bin server-id=3 binlog-ignore-db=information_schema binlog-ignore-db=performance_schema binlog-ignore-db=sys binlog-ignore-db=mysql replicate-do-db=yzdd replicate-ignore-db=mysql log-slave-updates slave-skip-errors=all slave-net-timeout=60 ~~~ stop slave; #关闭Slave change master to master_host='localhost',master_user='root',master_password='dongshang2018',master_log_file='mysql-bin.000004', master_log_pos=28125; start slave ~~~ 四: stop slave; start slave; reset master; reset slave; show master status; show slave status \g; 取消mysql的salve设置 stop slave; change master to master_host=' '; mysql> show slave status \G Empty set (0.00 sec)