Skip to content
Latchkey

MySQL "ERROR 1045 (28000): Access denied for user" in CI

MySQL accepted the connection and rejected the credentials. ERROR 1045 means the user/password combination is wrong, or the user has no grant from this host. The "(using password: YES/NO)" hint tells you whether a password was even sent.

What this error means

mysql/migrate fails with "ERROR 1045 (28000): Access denied for user 'root'@'...' (using password: YES)". It fails identically every run because it is a credential/grant mismatch.

mysql
ERROR 1045 (28000): Access denied for user 'app'@'172.18.0.1'
(using password: YES)

Common causes

Wrong password

The password in the connection string differs from MYSQL_PASSWORD/MYSQL_ROOT_PASSWORD configured on the service.

Password not sent ("using password: NO")

An empty/unset secret means the client sends no password to a server that requires one.

No grant from the connecting host

The user exists but has no privileges from the CI client host, so access is denied.

How to fix it

Align credentials between service and client

.github/workflows/ci.yml
services:
  mysql:
    image: mysql:8
    env:
      MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
      MYSQL_DATABASE: app
env:
  DATABASE_URL: mysql://root:${{ secrets.MYSQL_PASSWORD }}@127.0.0.1:3306/app

Check the password is actually present

  1. If you see "using password: NO", the secret is empty - fix the secret name/availability.
  2. Confirm the user has a grant from % (any host) for CI clients.
  3. Recreate the user/grant if an init script set different values.

How to prevent it

  • Use one secret for the MySQL password across service and client.
  • Grant CI users from % or the appropriate host.
  • Retrying will not fix an access-denied error - it is deterministic; fix the credential or grant.

Frequently asked questions

What causes ""ERROR 1045: Access denied for user""?
The password in the connection string differs from MYSQL_PASSWORD/MYSQL_ROOT_PASSWORD configured on the service.
How do I fix "ERROR 1045: Access denied for user"?
Align credentials between service and client

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card