//执行sql 设置从库名为:slave 密码:123456
grant replication slave on *.* to 'slave'@'%' identified by '123456';
查看主库 log-bin是否开启
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.00 sec)
查看主库 master状态,日志Position
mysql> show master status \G;
*************************** 1. row ***************************
File: mysql-bin.000002
Position: 4170
Binlog_Do_DB: test3,test3
Binlog_Ignore_DB: mysql,mysql
1 row in set (0.00 sec)
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 111.230.128.127
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 1305
Relay_Log_File: izwz9fgwaldgwiyc3d37ztz-relay-bin.000002
Relay_Log_Pos: 150
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: No
Slave_SQL_Running: Yes
Last_IO_Errno: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the first event 'mysql-bin.000001' at 1305, the last event read from './mysql-bin.000001' at 1305, the last byte read from './mysql-bin.000001' at 1324.'
注意:::
//当Slave_IO_Running 和 Slave_SQL_Running 都为 yes 时,配置成功
Slave_IO_Running为no 在下面 Last_IO_Error 显示了上次连接错误原因,可进行更改后。
进行 stop slave; CHANGE MASTER TO ...... ; start slave; 即可成功