MySQLMySQL 1045

MySQL 1045: Access Denied for User

MySQL 1045 means the server rejected the login attempt because the username/password combination does not match any account or the account lacks the CONNECT privilege. The connection is refused before any query runs.

Example Query

-- Triggered at connection time:
mysql -u app_user -p'wrong_password' mydb

Common Causes

  1. 1Incorrect password or username in the connection string
  2. 2The user account exists only for a different host (e.g. localhost vs %)
  3. 3Password was changed or the account was dropped without updating the application config

How to Fix It

Verify the username and password in your application config. Check that the MySQL account grants access from the host your app connects from with SHOW GRANTS FOR 'user'@'host'. Reset the password with ALTER USER if needed.

Need a reliable database?

Try Supabase — free PostgreSQL with a generous free tier. No credit card required.

Get started free →

Got a query causing this error?

Paste it into SQLbuddy and get an instant plain-English explanation with optimization tips.

Analyze My Query →