mysqlseverity: workaround
1045

MySQL Error 1045: Access denied for user

Access denied for user (using password: YES)

88% fixable~15 mindifficulty: intermediate

Verified against MySQL 9.0 docs (error-codes), Stack Overflow #1412284, MySQL Reference Manual · Updated April 2026

> quick_fix

The MySQL user/password combo is invalid, OR the user exists but isn't allowed to connect from your host. First confirm the credentials, then check if a user exists for the host you're connecting from.

-- Connect as root (adjust host as needed)
mysql -u root -p

-- See all users and their host permissions
SELECT user, host FROM mysql.user WHERE user = 'your_user';

-- Create a user for your specific host (or use % for any)
CREATE USER 'your_user'@'%' IDENTIFIED BY 'your_password';
GRANT ALL ON your_db.* TO 'your_user'@'%';
FLUSH PRIVILEGES;

What causes this error

MySQL authenticates the triple (user, password, host). Error 1045 fires if any of the three is wrong. Common gotcha: `alice@localhost` and `alice@%` are different users. If you created `alice@localhost` and try to connect from another machine, MySQL returns 1045 even with the right password.

> advertisementAdSense placeholder

How to fix it

  1. 01

    step 1

    Confirm the exact credentials

    Re-type the password (no copy-paste — invisible characters can sneak in). Confirm the user spelling.

  2. 02

    step 2

    Check which host patterns exist for the user

    Log in as root and query mysql.user. The host pattern matters — `alice@localhost` only allows connections from the server itself.

    SELECT user, host FROM mysql.user WHERE user = 'alice';
  3. 03

    step 3

    Create or update the user for your connecting host

    If no row matches your host, create one. Use % to allow any host (common for dev; restrict in production).

  4. 04

    step 4

    For reset passwords: use ALTER USER

    Don't use UPDATE mysql.user on MySQL 8+. Use ALTER USER with the correct auth plugin.

    ALTER USER 'alice'@'%' IDENTIFIED BY 'newpassword';
    FLUSH PRIVILEGES;

Frequently asked questions

Why does MySQL say access denied for root with no password?

MySQL 8+ installs root with auth_socket (on Ubuntu) — you can only log in as the actual OS root via `sudo mysql`. Set a password with ALTER USER to enable standard password auth.

What does "using password: YES" mean?

It means you supplied a password but it was wrong (or the user/host didn't match). "using password: NO" means you connected with no password at all.

disclosure:Errordex runs AdSense and has zero affiliate links or sponsored content. Every fix is manually verified against official sources listed in the “sources” sidebar. If a fix here didn’t work for you, please email so we can update the page.