# 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`
- **Domain:** database
- **Category:** config_error
- **Error Code:** `1794`
- **Verification:** ai_generated
- **Fix Rate:** 95%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MySQL 8.0 | active | — | — |
| MySQL 5.7 | active | — | — |
| MariaDB 10.5 | active | — | — |

## Workarounds

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** (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
   ```
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.** (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.
   ```

## Dead Ends

- **Restarting the MySQL service without changing configuration** — The server-id remains 0 or unset after restart; the error persists. (95% fail)
- **Setting server-id to 0 explicitly in my.cnf** — MySQL ignores server-id=0 and still requires a positive integer value. (90% fail)
- **Resetting replication with RESET SLAVE without fixing server-id** — RESET SLAVE clears replication state but does not change the server-id; error returns on next START SLAVE. (85% fail)
