{
  "id": "database/mysql-access-denied-for-root",
  "signature": "ERROR 1698 (28000): Access denied for user 'root'@'localhost'",
  "signature_zh": "错误 1698 (28000): 用户 'root'@'localhost' 访问被拒绝",
  "regex": "ERROR 1698 \\(28000\\): Access denied for user 'root'@'localhost'",
  "domain": "database",
  "category": "auth_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "MySQL 的 'root' 用户配置为通过 'auth_socket' 或 'unix_socket' 插件进行身份验证，这要求客户端通过 Unix 套接字以系统 root 用户身份连接，而不是使用密码。",
  "versions": [
    {
      "version": "MySQL 8.0.33",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MySQL 8.0.35",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MariaDB 10.11.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The command itself fails with the same error because it cannot authenticate as root without the socket plugin.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This disables all authentication, creating a severe security risk. It should only be used temporarily for recovery.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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;`",
      "success_rate": 0.9,
      "how": "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;`",
      "condition": "",
      "sources": []
    },
    {
      "action": "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;`",
      "success_rate": 0.85,
      "how": "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;`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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;`",
    "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;`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://dev.mysql.com/doc/refman/8.0/en/access-denied.html",
  "official_doc_section": null,
  "error_code": "1698",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-02-14",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}