您好,登录后才能下订单哦!
本篇内容介绍了“怎么使用MySQL master/slave”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
Master my.ini
basedir = D:\mysql_test\mysql-5.7.17-master
datadir = D:\mysql_test\mysql-5.7.17-master\data
port = 3306
log-bin=mysql-bin
server_id=1
binlog-ignore-db=information_schema
binlog-ignore-db=cluster
binlog-ignore-db=mysql
binlog-do-db=test
Slave my.ini
basedir = D:\mysql_test\mysql-5.7.17-slave
datadir = D:\mysql_test\mysql-5.7.17-slave\data
port = 3307
log-bin=mysql-bin
server-id=2
binlog-ignore-db=information_schema
binlog-ignore-db=cluster
binlog-ignore-db=mysql
replicate-do-db=test
replicate-ignore-db=mysql
log-slave-updates
slave-skip-errors=all
slave-net-timeout=60
Master 运行
mysql> CREATE USER 'rep'@'%' IDENTIFIED BY 'rep';
mysql> GRANT FILE ON *.* TO 'rep'@'%' IDENTIFIED BY 'rep';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'rep'@'%' IDENTIFIED BY 'rep';
mysql> FLUSH PRIVILEGES;
mysql> show master status;
+------------------+----------+--------------+----------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+----------------------------------+-------------------+
| mysql-bin.000002 | 4570 | test | information_schema,cluster,mysql | |
+------------------+----------+--------------+----------------------------------+-------------------+
Slave 运行
mysql> CREATE USER 'rep'@'%' IDENTIFIED BY 'rep';
mysql> change master to master_host='localhost',master_user='rep',master_password='rep',master_log_file='mysql-bin.000002', master_log_pos=4570;
mysql> start slave;
mysql> show slave status;
Slave_IO_Running 和 Slave_SQL_Running都是 Yes 表示成功。
Master创建数据库,创建表,添加数据,会自动复制到Slave。
“怎么使用MySQL master/slave”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。