简单的MySQL数据库主从同步配置【vnsc5858威尼斯城

时间:2019-12-10 13:49来源:计算机教程
mysql GRANT replication slave ON *.* TO 'slave'@'192.168.1.2'IDENTIFIED BY 'passwd';  mysql FLUSH privileges;  代码如下 Slave配置: server-id =2   Master新增slave账号:  代码如下   开始同步: 重启Master MySQL,查

mysql> GRANT replication slave ON *.* TO 'slave'@'192.168.1.2' IDENTIFIED BY 'passwd'; 
mysql> FLUSH privileges;

 代码如下

  Slave配置:

server-id =2

 

  Master新增slave账号:

 代码如下

 

  开始同步:

  重启Master MySQL,查看Master状态信息,记住File名称,POS位置。

 代码如下

 代码如下

  查看Slave同步状态:

 

mysql> SHOW slave STATUSG;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

log-bin = mysql-bin
server-id = 1
binlog-do-db = powerdns #要同步的数据库

 

 

 代码如下

mysql> show master status; 
------------------ ---------- -------------- ------------------
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
------------------ ---------- -------------- ------------------
| mysql-bin.000002 |      309 | powerdns     | mysql            |
------------------ ---------- -------------- ------------------
1 row in set (0.00 sec)

http://www.bkjia.com/Mysql/768908.htmlwww.bkjia.comtruehttp://www.bkjia.com/Mysql/768908.htmlTechArticleMaster配置: 代码如下 log-bin = mysql-bin server-id = 1 binlog-do-db = powerdns #要同步的数据库 Master新增slave账号: 代码如下 mysql GRANT replication slave...

   Master配置:

mysql> CHANGE master TO master_host='192.168.1.1',master_user='slave',master_password='passwd',
master_log_file='mysql-bin.000002',master_log_pos=309; 
mysql> START slave;

 代码如下

 

编辑:计算机教程 本文来源:简单的MySQL数据库主从同步配置【vnsc5858威尼斯城

关键词: