How to Fix MySQL Error 1698 (ER_ACCESS_DENIED_NO_PASSWORD_ERROR)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mysql error 1698 when a user tries to log in with the wrong method. You can fix it by creating a dedicated app user or matching the system account. This failure returns SQLSTATE 28000 and the symbol ER_ACCESS_DENIED_NO_PASSWORD_ERROR. The server blocks the session and prints an access denied message for that user and host. Database admins see this issue right after a fresh install or an upgrade. Why mysql error 1698 happens in your database Modern Linux systems set up the root databa

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mysql error 1698 when a user tries to log in with the wrong method. You can fix it by creating a dedicated app user or matching the system account.

This failure returns SQLSTATE 28000 and the symbol ER_ACCESS_DENIED_NO_PASSWORD_ERROR. The server blocks the session and prints an access denied message for that user and host. Database admins see this issue right after a fresh install or an upgrade.

Why mysql error 1698 happens in your database

Modern Linux systems set up the root database user to use operating system credentials. Instead of a password, the database checks your current Linux user account name. It uses a local socket plugin to read the user ID from the system.

If you run a client as a normal Linux user, the names do not match. The database expects the system root account, so it rejects the login attempt right away. Even if you type a password, the server ignores it and returns mysql error 1698.

This also happens when a web app tries to log in over a network port. Socket plugins only work for local traffic on the same host machine. Remote clients or containers cannot pass a local system user ID over the network.

Another cause is a broken user table after a migration from an older server. An admin might copy user accounts without setting up the right login plugin. When the client sends a password, the server does not know how to check it.

How to diagnose the login failure

First, check which Linux account is running your client tool or web app. Next, log in to the database as the system root user from the host terminal. Once inside, inspect the user table to see which plugin each account uses.

Look at the user name, the host value, and the assigned login plugin column. If the account uses the socket plugin, password logins will always fail for that user. You should also verify the host value matches where your app runs.

Application-to-Application Password Management + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Check your server logs to see the exact user and host pair that failed. Sometimes an app falls back to a blank user name when a config file fails. The error message will show the exact user and host string the server received.

How to fix the error safely in production

Many guides tell you to switch the root account back to a password plugin. Doing that weakens your server security and exposes the admin account to brute force attacks. Keep the root user locked to the local system account for admin tasks only.

The safest fix is to create a new database user just for your app. Set up this new account with a strong password plugin and a strict host rule. Grant this user only the exact table permissions your app needs to run.

If a human engineer needs to run queries, create a separate role for them too. Never share the root account across scripts, apps, or team members. Update your app config to use the new user name and password pair.

Test the new login from the app host to confirm the error is gone. For sensitive tables, pair least-privilege roles with data masking to rewrite emails or card numbers. This keeps production data safe while your team fixes app issues.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

Why does mysql error 1698 happen even when I type the right password?

The user account is set up to check your Linux user ID instead of passwords. The database ignores the password you typed and blocks the login because the accounts mismatch.

Should I change the root user plugin to fix this error?

No, leaving root on the socket plugin protects your server from network password attacks. Create a separate user account with limited permissions for your app or client tool instead.

Why did my local script start getting error 1698 after a server update?

System updates can reset default user rules or change which Linux user runs your script. Check the cron job or service file to see which system account runs the script.

The query runs. The emails stay hidden.