從庫執行 START SLAVE 報 ERROR 1200: The server is not configured as slave,核心原因是配置文件 my.ini 中殘留舊式主從參數(master-host 等)與新式 CHANGE MASTER TO 衝突。MySQL 5.1+ 已棄用配置文件方式,必須純用 SQL 命令。
-- 從庫 my.ini 含有如下廢棄參數
service-id=2
master-host=192.168.1.103
master-user=repl
master-password=111111
master-port=3306
replicate-do-db=ld
log-bin=mysql-bin
即使執行了 CHANGE MASTER TO ...,啟動時仍讀取舊參數並嘗試舊邏輯,導致 1200。
[mysqld]
server-id=2
relay-log=relay-bin
relay-log-index=relay-bin.index
log-slave-updates=1
read-only=1
skip-slave-start=1
# replicate-do-db 等過濾參數可保留,或改用 CHANGE REPLICATION FILTER
CHANGE MASTER TO
MASTER_HOST='192.168.1.103',
MASTER_USER='repl',
MASTER_PASSWORD='111111',
MASTER_LOG_FILE='master-bin.000001',
MASTER_LOG_POS=107;
START SLAVE;
SHOW SLAVE STATUS\G
-- 確認
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
[mysqld]
server-id=1
log-bin=master-bin
binlog-do-db=ld
binlog-ignore-db=mysql
binlog_format=ROW
expire_logs_days=7
master-* 參數:master-host/user/password/port/connect-retry/ssl* 均屬廢棄。GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.1.%',避免 % 安全風險。ntpdate pool.ntp.org,防止 Binlog 位置計算偏差。