// MySQL error reference

MySQL error 1698: Access denied for user (no password)

Login denied for an account that authenticates without a password check, most often root using auth_socket on Ubuntu or Debian.

Error number
1698
Name
ER_ACCESS_DENIED_NO_PASSWORD_ERROR
SQLSTATE
28000
Category
Access and privileges
Error message
Access denied for user '%s'@'%s'

What it means

1698 is an access-denied error for accounts whose plugin doesn't take a password. On Ubuntu and Debian, 'root'@'localhost' uses auth_socket, which lets you in only if your operating-system user is also root. Logging in as root from a normal user, or from an app with a password, fails with 1698.

Common causes

  • Running mysql -u root -p as a normal operating-system user on a system where root uses auth_socket.
  • An application connecting as root with a password to such a server.

How to fix it

  1. Log in as the operating-system root user, which auth_socket accepts: sudo mysql.

  2. Create a separate account with a password for applications and tools, instead of changing root.

    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'strong-password';
    GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
  3. Or, if you really want password login for root, change its plugin.

    ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'strong-password';

Related errors

More access and privileges errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.