mysql主从同步配置简单方法,建立主从关系,实现mysql主从同步,mysql主从同步的配置步骤,需要的朋友参考下。
项目需求:
实现步骤:
[root@itnetcn~]#vim/etc/my.cnf
[mysqld] server_id=31 log_bin [root@itnetcn~]#servicemysqlrestart
mysql>grantreplicationslaveon*.*toslave@"192.168.1.32"identifiedby"123";
[root@itnetcn~]#vim/etc/my.cnf
[mysqld] server_id=32 [root@jbxue~]#servicemysqlrestart
mysql>changemasterto
->master_host="192.168.1.31", ->master_user="slave", ->master_password="123", ->master_log_file="localhost-bin.000001", ->master_log_pos=472;
5、开启从数据库同步功能
复制代码代码示例:
mysql>startslave;
补充一句:
mysql> show master status;
+------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | localhost-bin.000001 | 472| | mysql |
这个可以解释:
mysql>changemasterto
->master_host="192.168.1.31", ->master_user="slave", ->master_password="123", ->master_log_file="localhost-bin.000001", ->master_log_pos=472; 其中master_log_file和master_log_pos两个参数的值是怎么得到的。 (责任编辑:IT) |