这篇文章主要为大家详细介绍了MySQL数据库互为主从配置方法分享,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编小韵来看看吧!
mysql主从配置小记:代码如下:
INSERT INTO user (Host,User, Password,Select_priv,Insert_priv,Update_priv,Delete_priv, Create_priv,Drop_priv) VALUES('%','test',password('test'),'Y','Y','Y','Y','Y','Y');
代码如下:
FLUSH PRIVILEGES;
代码如下:
server-id = 1
replicate-do-db=test
replicate-do-db=test_admin
log-bin=mysql-bin
log-slave-updates
replicate-wild-do-table=test.%
replicate-wild-do-table=test_admin.%
binlog-ignore-db=mysql
slave-skip-errors=all
代码如下:
server-id = 3
binlog-do-db=test
binlog-do-db=test_admin
log-bin=mysql-bin
log-slave-updates
replicate-wild-do-table=test.%
replicate-wild-do-table=test_admin.%
binlog-ignore-db=mysql
slave-skip-errors=all
代码如下:
slave stop;
代码如下:
reset master;
代码如下:
GRANT REPLICATION SLAVE ON *.* TO 'test'@'%' IDENTIFIED BY 'test';
代码如下:
flush privileges;
代码如下:
flush tables with read lock;
代码如下:
slave stop;
代码如下:
CHANGE MASTER TO MASTER_HOST='10.1.10.28', MASTER_USER='test', MASTER_PASSWORD='test', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;
代码如下:
slave stop;
代码如下:
reset master;
代码如下:
GRANT REPLICATION SLAVE ON *.* TO 'test'@'%' IDENTIFIED BY 'test';
代码如下:
flush privileges;
代码如下:
flush tables with read lock;
代码如下:
slave stop;
代码如下:
CHANGE MASTER TO MASTER_HOST='10.1.10.30', MASTER_USER='test', MASTER_PASSWORD='test', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;
代码如下:
server-id = 2
replicate-do-db=test
replicate-do-db=test_admin
log-bin=mysql-bin
log-slave-updates
replicate-wild-do-table=test.%
replicate-wild-do-table=test_admin.%
binlog-ignore-db=mysql
slave-skip-errors=all
代码如下:
slave stop;
代码如下:
CHANGE MASTER TO MASTER_HOST='10.1.10.28', MASTER_USER='test', MASTER_PASSWORD='test', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;
代码如下:
slave start;
代码如下:
server-id = 4
replicate-do-db=test
replicate-do-db=test_admin
log-bin=mysql-bin
log-slave-updates
replicate-wild-do-table=test.%
replicate-wild-do-table=test_admin.%
binlog-ignore-db=mysql
slave-skip-errors=all
代码如下:
slave stop;
代码如下:
CHANGE MASTER TO MASTER_HOST='10.1.10.30', MASTER_USER='test', MASTER_PASSWORD='test', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;
代码如下:
slave start;
本文来自:http://www.q1010.com/177/10261-0.html
注:关于MySQL数据库互为主从配置方法分享的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:MYSQL
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。