mysql> change master to master_host='172.16.22.1',master_user='test',master_password='test',master_log_file='mysql-bin.000030',master_log_pos=337;
mysql> change master to master_host='192.168.40.176',master_port=3306,master_user='repl',master_password='123456',master_auto_position=1,master_delay=20; --master_delay此参数表示relay日志会同步到slave机,但是会根据事件时间戳延时20秒
// master_host 主库IP
//master_user 上面创建的复制用户名
//master_passowrd 用户密码
// master_log_file 从那个二进制文件开始复制
//master_log_pos 从二进制文件的哪个位置开始复制
mysql> start slave;
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.22.1
Master_User: test
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000031
Read_Master_Log_Pos: 185029
Relay_Log_File: mysql-relay-bin.000004
Relay_Log_Pos: 185175
Relay_Master_Log_File: mysql-bin.000031
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 185029
Relay_Log_Space: 185477
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
ERROR:
No query specified
Slave_IO_Running、Slave_SQL_Running都为Yes即成功了。
任何一个显示为No,检查网络、用户、用户名、二进制文件