开启两台mysql log-bin.log
server_id不能相同 设置从服务器server_id=2;
主服务器建立一个主从账号
GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' IDENTIFIED BY '1234';
查看主服务器信息(主要是file,position供从服务器使用)
SHOW MASTER STATUS;
stop
CHANGE MASTER TO
MASTER_HOST='192.168.3.175',MASTER_USER='slave',MASTER_PASSWORD='1234',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=154;
START SLAVE;
查看主从状态
show slave status;
//两项yes代表成功
slave_io_running yes
slave_sql_running yes