怎么使用MySQLmaster/slave-创新互联
本篇内容介绍了“怎么使用MySQL master/slave”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
专注于为中小企业提供成都网站设计、成都做网站、外贸网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业新丰免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了1000多家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。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”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联-成都网站建设公司网站,小编将为大家输出更多高质量的实用文章!
新闻标题:怎么使用MySQLmaster/slave-创新互联
文章出自:http://myzitong.com/article/dipegg.html