systemctl restart mysqld.service
# 查看状态
systemctl status mysqld.service
配置主从关联
主机配置
登录主机mysql控制台,创建用户,授权并刷新。
mysql -u root -p
create user 'repl'@'%' identified by 'mysql57*';
grant replication slave on *.* to 'repl'@'%' identified by 'mysql57*';
flush privileges;
从机配置
mysql -u root -p
# 这里我的主机ip是192.168.1.8
change master to master_host='192.168.1.8',master_port=3306,master_user='repl',master_password='mysql57*',master_log_file='master-bin.000001',master_log_pos=0;
start slave;
#停止主从同步
#stop slave;
# \g 表示换行查看
show slave status \g;
若查看主从状态提示the slave i/o thread stops because master and slave have equal mysql server uuids; these uuids must be different for replication to work.请参考常见问题