# ERROR 1698 (28000): Access denied for user 'root'@'localhost'

- **ID:** `database/mysql-access-denied-for-root`
- **Domain:** database
- **Category:** auth_error
- **Error Code:** `1698`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

MySQL's 'root' user is configured to authenticate via 'auth_socket' or 'unix_socket' plugin, which requires the client to connect from the system root user via Unix socket, not with a password.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MySQL 8.0.33 | active | — | — |
| MySQL 8.0.35 | active | — | — |
| MariaDB 10.11.6 | active | — | — |

## Workarounds

1. **Connect using sudo: `sudo mysql -u root`. Then change the authentication plugin: `ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password'; FLUSH PRIVILEGES;`** (90% success)
   ```
   Connect using sudo: `sudo mysql -u root`. Then change the authentication plugin: `ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password'; FLUSH PRIVILEGES;`
   ```
2. **Create a new admin user with mysql_native_password: `CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;`** (85% success)
   ```
   Create a new admin user with mysql_native_password: `CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;`
   ```

## Dead Ends

- **** — The command itself fails with the same error because it cannot authenticate as root without the socket plugin. (90% fail)
- **** — This disables all authentication, creating a severe security risk. It should only be used temporarily for recovery. (50% fail)
