1794 database config_error ai_generated true

ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave.

ID: database/mysql-replica-lag-binlog-not-purged

Also available as: JSON · Markdown · 中文
95%Fix Rate
85%Confidence
1Evidence
2023-09-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
MySQL 8.0 active
MySQL 5.7 active
MariaDB 10.5 active

Root Cause

MySQL replication slave fails to start because the server-id is not set or is set to 0, which is required for replication to function.

generic

中文

MySQL 复制从库无法启动,因为未设置 server-id 或设置为 0,而复制功能要求必须设置该参数。

Official Documentation

https://dev.mysql.com/doc/refman/8.0/en/replication-options.html#option_mysqld_server-id

Workarounds

  1. 95% success Set server-id to a unique positive integer (e.g., 1) in my.cnf under [mysqld] section, then restart MySQL: [mysqld] server-id=1
    Set server-id to a unique positive integer (e.g., 1) in my.cnf under [mysqld] section, then restart MySQL:
    [mysqld]
    server-id=1
  2. 85% success If MySQL is already running, set server-id dynamically (requires restart for full effect, but can be set at runtime in MySQL 8.0+): SET GLOBAL server_id = 1; Then restart the service.
    If MySQL is already running, set server-id dynamically (requires restart for full effect, but can be set at runtime in MySQL 8.0+):
    SET GLOBAL server_id = 1;
    Then restart the service.

中文步骤

  1. Set server-id to a unique positive integer (e.g., 1) in my.cnf under [mysqld] section, then restart MySQL:
    [mysqld]
    server-id=1
  2. If MySQL is already running, set server-id dynamically (requires restart for full effect, but can be set at runtime in MySQL 8.0+):
    SET GLOBAL server_id = 1;
    Then restart the service.

Dead Ends

Common approaches that don't work:

  1. Restarting the MySQL service without changing configuration 95% fail

    The server-id remains 0 or unset after restart; the error persists.

  2. Setting server-id to 0 explicitly in my.cnf 90% fail

    MySQL ignores server-id=0 and still requires a positive integer value.

  3. Resetting replication with RESET SLAVE without fixing server-id 85% fail

    RESET SLAVE clears replication state but does not change the server-id; error returns on next START SLAVE.