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.
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
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/appCheck the password is actually present
- If you see "using password: NO", the secret is empty - fix the secret name/availability.
- Confirm the user has a grant from
%(any host) for CI clients. - 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.