mysqkl主从配置

主ip:192.168.0.102
从ip:192.168.0.105
配置主msyql:

[root@localhost ~]#vi /etc/my.cnf
在[mysqld]下添加:
server-id=1
log-bin=mysql-bin

进入mysql执行:
GRANT REPLICATION SLAVE ON *.* to
'root'@'192.168.0.105' identified by '123456';
show master;
/etc/init.d/mysqld restart

配置从mysql:

[root@localhost ~]#vi /etc/my.cnf
在[mysqld]下添加:
server-id=2
log-bin=mysql-bin
/etc/init.d/mysqld restart

进入mysql执行:
CHANGE MASTER TO  MASTER_HOST='192.168.0.102',
MASTER_USER='root',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=98,
MASTER_CONNECT_RETRY=10;


show slave status\G;
看到两个YES就说明成功了。


本文出自 “liunx系统” 博客,谢绝转载!

你可能感兴趣的:(mysql)