mysqldude
Error codes › 1698

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

Error messageAccess denied for user '…'@'…'
Example from our test runs: Access denied for user 'sockuser'@'localhost' (5.6.51)

The account authenticates by operating-system user (auth_socket on MySQL, unix_socket on MariaDB), and you aren't logged in to Linux as that user. Classic case: 'mysql -u root' without sudo on Ubuntu/Debian.

MySQLMariaDB
SymbolER_ACCESS_DENIED_NO_PASSWORD_ERRORER_ACCESS_DENIED_NO_PASSWORD_ERROR
SQLSTATE2800028000
TypeServer errorServer error
Versionssince 5.5.63 activeevery release since 5.5 active

What it means

1698 is a “you’re not who this account trusts” error. The account doesn’t check a password: the auth_socket (MySQL) or unix_socket (MariaDB) plugin compares the database user name with the operating-system user of the client process on the other end of the Unix socket. When they don’t match, login fails with 1698 rather than 1045.

Why it happens

  • On Ubuntu and Debian, the distribution packages create 'root'@'localhost' with socket authentication. sudo mysql works; mysql -u root -p from your own login, or from a PHP or Python application, fails with 1698 whatever password you type.
  • MariaDB 10.4+ creates root@localhost with unix_socket or a password, so it works both ways. Other socket-only accounts behave as above.
  • An account was switched to socket authentication to “secure” it, and an application still uses a password.
  • Socket authentication only works over the Unix socket, so a TCP connection (-h 127.0.0.1) to such an account also fails.

How to fix it

  • Run the client as the matching OS user: sudo mysql for root.
  • Better for applications: don’t use root at all. Create a dedicated account with a password: CREATE USER 'app'@'localhost' IDENTIFIED BY '…'; GRANT … ON shop.* TO 'app'@'localhost';.
  • To give an existing socket account a password, switch its plugin (see the replay below). On MariaDB, ALTER USER root@localhost IDENTIFIED VIA unix_socket OR mysql_native_password USING PASSWORD('…') keeps both ways of logging in.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database:

    CREATE DATABASE demo;
    USE demo;
  2. Create an account that trusts the operating-system user instead of a password. MySQL needs the auth_socket plugin; MariaDB has unix_socket built in.

    -- MySQL
    INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';
    CREATE USER 'sockuser'@'localhost' IDENTIFIED WITH auth_socket;
    -- MariaDB
    CREATE USER 'sockuser'@'localhost' IDENTIFIED VIA unix_socket;
  3. Log in as that account while logged in to Linux as someone else (here, root). This is what happens with 'mysql -u root' on a fresh Ubuntu/Debian install when you are not using sudo.

    mysql -u sockuser -e 'SELECT 1'

You get: ERROR 1698 (28000): Access denied for user 'sockuser'@'localhost'(11.8.9)

Verified fixes

  1. Give the account a password-based plugin (or run the client as the matching OS user, e.g. sudo mysql)

    Switch the account to password authentication:

    -- MySQL 8.0+
    ALTER USER 'sockuser'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'Test#1234';
    -- MySQL 5.6 (ALTER USER can't change the plugin)
    UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'sockuser';
    FLUSH PRIVILEGES;
    SET PASSWORD FOR 'sockuser'@'localhost' = PASSWORD('Test#1234');
    -- MySQL 5.7
    ALTER USER 'sockuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Test#1234';
    -- MariaDB
    ALTER USER 'sockuser'@'localhost' IDENTIFIED VIA mysql_native_password USING PASSWORD('Test#1234');

    Then log in with the password:

    mysql -u sockuser -p -e 'SELECT CURRENT_USER()'

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
An account that authenticates by OS user (auth_socket / unix_socket), used from a different OS user
repro
✓ 1698✓ 1698✓ 1698✓ 1698✓ 1698✓ 1698✓ 1698✓ 1698✓ 1698
Give the account a password-based plugin (or run the client as the matching OS user, e.g. sudo mysql)
fix
✓✓✓✓✓✓✓✓✓
An account that authenticates by OS user (auth_socket / unix_socket), used from a different OS user repro
MySQL 5.6✓ 16985.7✓ 16988.0✓ 16988.4✓ 16989✓ 1698
MariaDB 10.6✓ 169810.11✓ 169811.4✓ 169811.8✓ 1698
Give the account a password-based plugin (or run the client as the matching OS user, e.g. sudo mysql) fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors

  • 1045 ER_ACCESS_DENIED_ERRORexplained
  • 1524 ER_PLUGIN_IS_NOT_LOADED
  • 2059 CR_AUTH_PLUGIN_CANNOT_LOAD