主数据库
创建用户 GRANT REPLICATION SLAVE ON *.* to 'mysync'@'%' identified by 'mysync';
查看状态 show master status;
从数据库
change master to
master_host='192.168.1.106',
master_user='mysync',
master_password='mysync',
master_port=3306,
master_log_file='mysql-bin.000267',
master_log_pos=1131;
报错 :
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
解决:
show variables like "sql_mode";
set sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';
change master to
master_host='192.168.1.106',
master_user='mysync',
master_password='mysync',
master_port=3306,
master_log_file='mysql-bin.000267', # 根据主id而定
master_log_pos=1131; # 根据主id而定
# 启动复制功能
start slave;
#查看复制状态
show slave status