“MySQL access denied” means your client lacks the correct username, password, or privileges to connect or run statements.
The server rejects the connection or statement because the supplied credentials or host do not match a privilege entry in mysql.user
. Either the password is wrong, or the user lacks GRANTed rights.
Run SELECT user, host FROM mysql.user WHERE user='app_user';
. Confirm that the connecting host (IP or “%”) appears.If not, create the appropriate account-host pair.
Use GRANT ALL PRIVILEGES ON ecommerce.* TO 'app_user'@'10.%' IDENTIFIED BY 'STRONGPASS';
. Flush privileges or reconnect for changes to take effect.
Limit rights: GRANT SELECT ON ecommerce.* TO 'analyst'@'%' IDENTIFIED BY 'ROPASS';
. Least privilege avoids accidental writes.
Reset with ALTER USER 'app_user'@'10.%' IDENTIFIED BY 'NEWPASS';
.Update application secrets immediately.
Create separate accounts per env (e.g., app_user_dev
, app_user_prod
) and restrict hosts to VPC subnets. This eliminates cross-environment leaks.
Yes. If REQUIRE SSL
is specified but the client connects unencrypted, MySQL rejects with the same error. Ensure --ssl-mode=REQUIRED
and valid certificates.
.
No. Use ALTER USER ... IDENTIFIED BY
to update the password in place.
Yes. It gives full rights on every database. Prefer per-schema grants such as ecommerce.*
.
FLUSH PRIVILEGES
always needed?Only if you modified privilege tables directly. GRANT and ALTER USER auto-reload privileges.