About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
ERROR 1698 (28000): Access denied for user 'root'@'localhost' is the access-denied error for a login that did not use a password. On a fresh Ubuntu or Debian install, root@localhost usually authenticates by the operating system user who runs the client, so typing a password, right or wrong, changes nothing. Run the client as that operating system user (sudo mysql or sudo mariadb), or create a separate account that logs in with a password.
What the error means
MySQL's error reference lists two similar entries. Error 1045 (ER_ACCESS_DENIED_ERROR, SQLSTATE 28000) has the message "Access denied for user '%s'@'%s' (using password: %s)". Error 1698 (ER_ACCESS_DENIED_NO_PASSWORD_ERROR, SQLSTATE 28000) has the message "Access denied for user '%s'@'%s'", with no "using password" part. The error reference gives no causes for either. MariaDB's page for error 1698 explains the difference: it is the variant of error 1045 for authentication that does not use a password, because, in its words, "no password was checked". A wrong password is covered by MySQL ERROR 1045 (28000) "Access denied for user": which account the server matched.
The most common reason is socket authentication. MySQL's plugin documentation says the auth_socket plugin "authenticates clients that connect from the local host through the Unix socket file", using the SO_PEERCRED socket option to learn "the user running the client program". It compares the operating system user name with the MySQL user name, and gives an example in which the plugin "determines that the --user option value (valerie) differs from the client user's name (stephanie) and refuses the connection". It adds that "the plugin refuses the connection even for valerie if the connection is made using a different protocol, such as TCP/IP."
The Ubuntu Server documentation for MySQL describes the default: mysql-server "initially provides a 'root'@'localhost' user", entered with sudo mysql -u root, and "No password is required by MySQL as it authenticates with auth_socket."
MariaDB works the same way with its unix_socket plugin. Its documentation says the root@localhost account created by mariadb-install-db is set up to try unix_socket first, and then mysql_native_password with an invalid password, so "there is no open-for-everyone all-powerful root account". The Debian and Ubuntu page says packages from those distributions' default repositories install the plugin by default and create root@localhost with it. MariaDB's error 1698 page states the consequence: "A password on the command line makes no difference, because the plugin doesn't check it."
MySQL's pages do not say in so many words that a refusal by auth_socket is reported as error 1698. The link between the two comes from the missing "using password" part and from MariaDB's page for the same error number, so the proof step below checks the account instead of assuming it.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
root@localhost uses socket authentication and you are another operating system user |
1698 for -u root, with or without -p |
sudo mysql (or sudo mariadb) connects, and SHOW CREATE USER 'root'@'localhost' names auth_socket or unix_socket |
| An application or tool connects with a password to a socket-authenticated account | 1698 in the application log | The same SHOW CREATE USER for the account the application uses |
| A TCP/IP connection to an account that accepts only the socket | 1698 over the network or --protocol=TCP, success through the socket |
The same user works by socket and fails by TCP/IP |
| MariaDB: a statement needs more privileges after you logged in | The error appears on a GRANT, not at login |
MariaDB's page names GRANT role TO ... without ADMIN OPTION and GRANT PROXY without the privilege |
| Windows with MariaDB named pipe | 1698 from a Windows user that does not match | MariaDB's page says named_pipe gives the same error |
Prove the cause before changing anything
1. Read the exact message. A 1698 message ends after the host name. If the message ends with a using password part, the error is 1045.
2. Try the documented socket login. Run it as an administrator who may use sudo:
sudo mysql
On MariaDB use sudo mariadb. The MariaDB page on authentication from MariaDB 10.4 adds that if a system-wide option file sets protocol=tcp, use sudo mariadb --protocol=socket. A good result is a prompt. That shows root is socket-authenticated and the failing login was by another operating system user or by TCP/IP.
3. Look at the account. At that prompt:
SHOW CREATE USER 'root'@'localhost';
The MySQL manual says this statement "shows the CREATE USER statement that creates the named user". The authentication part of the output names the plugin. Run it again for the account your application uses. The MySQL page says the statement needs the SELECT privilege on the mysql system schema, except for the current user; the MariaDB page says the same.
4. Find the operating system user the failing client runs as. For a service, read its definition. The failing user must be the one the account expects. For an account named root, that is the operating system user root.
Fix
The remedy depends on the cause.
- To administer the server, the documented login is
sudo mysqlorsudo mariadb. Nothing changes. - An application or tool that must log in with a password needs a separate account of its own. Root's method stays as it is, which is the safer choice.
- Giving
root@localhosta password as well is something MariaDB documents:ALTER USER 'root'@'localhost' IDENTIFIED VIA unix_socket OR mysql_native_password USING PASSWORD('…'), and warns on its ALTER USER page that omittingunix_socketfrom the clause removes socket login. That statement changes the authentication of the most privileged account, so it is only described here and is not one of the steps below.
Steps for the separate account. First save the list of existing accounts, from the shell:
sudo mysql -e "SELECT User, Host FROM mysql.user" > ~/mysql-users-before.2026-12-01.txt
The MySQL client documentation says --execute=statement, -e statement will "Execute the statement and quit". On MariaDB use sudo mariadb instead of sudo mysql.
Risk: the next statements create a new database account that can log in with a password, and give it rights. The password is subject to your server's password policy; if the server rejects it, see MySQL ERROR 1819 (HY000): Your password does not satisfy the current policy requirements.
At the sudo mysql prompt, create the account and give it only what it needs. The statement forms are those on the CREATE USER and Ubuntu pages; the account, the database appdb and the privilege are examples:
CREATE USER 'appuser'@'localhost' IDENTIFIED BY '<a password that meets the policy>';
GRANT SELECT ON appdb.* TO 'appuser'@'localhost';
The MySQL CREATE USER page says "An account when first created has no privileges and the default role NONE", so the GRANT is what gives it access.
To undo it: show the account first, to be sure it is the one you created, then drop it. The MySQL DROP USER page says the statement "removes one or more MySQL accounts and their privileges" and that it "does not automatically close any open user sessions".
SHOW CREATE USER 'appuser'@'localhost';
DROP USER 'appuser'@'localhost';
Compare SELECT User, Host FROM mysql.user; with the saved list afterwards; the two should match.
Example (illustrative): On db01 (Ubuntu with MySQL 8.4), a reporting script run by the operating system user report calls mysql -u root -p and gets ERROR 1698 (28000): Access denied for user 'root'@'localhost'. sudo mysql works, and SHOW CREATE USER 'root'@'localhost' names auth_socket. The engineer creates appuser as above for the one database the script reads, points the script at that account, and leaves root alone. The script now connects as appuser.
Confirm the fix
sudo mysqlstill gives a prompt as before.- The application or script connects with its new account:
mysql -u appuser -p appdbprompts for the password and reaches the database. - The old failing call is gone from the application's configuration, so 1698 no longer appears in its log.
What to watch afterwards
- Scripts that call
mysql -u root -pfrom cron or a service: they will fail again if root is changed back to socket authentication. - New admin users on the host: a socket-authenticated MySQL account matches the operating system user of the same name, so each person needs their own operating system login.
- The password rules of the server, when you add accounts.
Read next
Related articles you may want next.
- TroubleshootingMySQL ERROR 1045 (28000) "Access denied for user": which account the server matchedMySQL ERROR 1045 (28000) Access denied for user? Read the user, host and 'using password' text, find the account the server matched, then fix it.Read article
- TroubleshootingMySQL "Authentication plugin 'caching_sha2_password' cannot be loaded": an older client meets a MySQL 8 serverMySQL: Authentication plugin 'caching_sha2_password' cannot be loaded. Find the old client, upgrade it, or switch one account plugin with a back-out.Read article
- TroubleshootingMySQL ERROR 2002 "Can't connect to local MySQL server through socket": is it running, and which socketMySQL ERROR 2002 'Can't connect to local MySQL server through socket'? Check mysqld is running, find the real socket path, and fix the client.Read article
Risks and limits
- These commands have not been run or lab-tested.
- The MySQL pages are for version 8.4. MariaDB's pages describe 10.4 and later for the default root account; earlier versions and other distributions may differ.
- MySQL's pages do not say that a socket-plugin refusal is reported as error 1698; MariaDB's page does for MariaDB. The checks above confirm which case you have.
- Do not weaken root's socket authentication to fix one script. MariaDB's page lists the weaknesses of socket authentication and its strengths; read both before changing root.
- The
sudo mysql -estatement needssudorights on the server, and the saved list is written to the home folder of the user who runs it.
Sources
- Socket Peer-Credential Pluggable Authentication — MySQL 8.4 Reference Manual, no date shown, accessed 1 December 2026
- Server Error Message Reference — MySQL 8.4 Error Reference, no date shown, accessed 1 December 2026
- SHOW CREATE USER Statement — MySQL 8.4 Reference Manual, no date shown, accessed 1 December 2026
- CREATE USER Statement — MySQL 8.4 Reference Manual, no date shown, accessed 1 December 2026
- DROP USER Statement — MySQL 8.4 Reference Manual, no date shown, accessed 1 December 2026
- mysql Client Options — MySQL 8.4 Reference Manual, no date shown, accessed 1 December 2026
- Install and configure a MySQL server — Ubuntu Server documentation, no date shown, accessed 1 December 2026
- Error 1698: Access denied for user — MariaDB documentation, no date shown, accessed 1 December 2026
- Authentication Plugin - Unix Socket — MariaDB documentation, no date shown, accessed 1 December 2026
- Authentication from MariaDB 10.4 — MariaDB documentation, no date shown, accessed 1 December 2026
- Differences in MariaDB in Debian (and Ubuntu) — MariaDB documentation, no date shown, accessed 1 December 2026
- ALTER USER — MariaDB documentation, no date shown, accessed 1 December 2026
- SHOW CREATE USER — MariaDB documentation, no date shown, accessed 1 December 2026
This article was originally published on .