dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Error Library/mysql-1698-access-denied-root-localhost
MySQL
MySQL 5.7–8.4 LTSAuthentication & Plugins
6 min read
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

MySQL Error 1698 — Password Not Rejected, Never Even Checked?

Diagnosing Error 1698: why auth_socket ignores passwords, leveraging sudo mysql, migrating to caching_sha2_password, and distinguishing from Error 1045.

Reviewed by:Principal Database Reliability Architect
Tested Versions: MySQL 8.4 LTS, 8.0.40 & 5.7.44 (Debian / Ubuntu / Docker 29.7)

Operational Verification & Reliability Metadata

Last Technical Review: 30 Ekim 2026
Tested VersionsMySQL 8.4 LTS & 8.0.40 (Ubuntu 24.04 LTS, Debian Bookworm) | Tarihsel: 5.7
Required PrivilegesOS sudo/root privilege (to execute sudo mysql via auth_socket)
Risk Assessment
MediumCreating 'root'@'%' or leaving --skip-grant-tables active exposes the root catalog to internet intrusion
Expected OutputDetection of auth_socket, deliberate transition to caching_sha2_password or maintained sudo mysql workflow
Rollback Procedure:Enforce caching_sha2_password on root@localhost and provision isolated least-privilege application accounts
MySQL 8.4 Docs: Pluggable Socket Authentication (auth_socket)
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

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

SQLSTATE code: 28000.

On Debian and Ubuntu platforms, this error is a rite of passage: You execute mysql -u root -p, enter the password, and receive ERROR 1698.

The issue is neither privilege revocation nor an incorrect password: It is driven entirely by the authentication plugin architecture.

IMPORTANT
Understanding `auth_socket`: Your Password Is Never Evaluated! Native packages on Debian/Ubuntu configure root@localhost using the `auth_socket` plugin. This plugin ignores passwords entirely; instead, it matches the operating system effective user ID (UID) of the caller against the requested database account name. If you are not executing the client as the OS root user (via sudo), MySQL rejects the connection immediately, regardless of what password string you supply.

▸Distinguishing Error 1698 from Error 1045

  • •Error 1045 (`Access denied ... Using password: YES`): The password was evaluated and rejected (H-03).
  • •Error 1698: The password was never evaluated. Bypassing grant tables via --skip-grant-tables is completely unwarranted.

▸Diagnostic Step: Confirming `auth_socket`

Log in via elevated operating system credentials:

bash
sudo mysql

Inspect the plugin definition:

sql
SELECT user, host, plugin FROM mysql.user WHERE user = 'root';

If plugin is set to auth_socket, root is strictly bound to OS-level authentication.


▸Step-by-Step Resolution

Option 1: Migrate to Password Authentication (Local Dev Environments)

sql
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'StrongPassword123!'; FLUSH PRIVILEGES;
WARNING
Do not use mysql_native_password. It is deprecated in MySQL 8.0 and fully removed in MySQL 9.0. Standardize on `caching_sha2_password`.

Option 2: Preserve auth_socket for Hardened Production Nodes

In production, leaving root governed by auth_socket provides excellent defense-in-depth: Root access requires local SSH and sudo privileges, eliminating remote password stuffing risks. Provision dedicated application accounts for DML traffic:

sql
CREATE USER 'app_service'@'10.0.2.%' IDENTIFIED WITH caching_sha2_password BY 'AppSecurePassword!'; GRANT SELECT, INSERT, UPDATE, DELETE ON app.* TO 'app_service'@'10.0.2.%';

▸Related Error Guides & Hub Links

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (50)