Migrate to Percona software for MySQL – an open source, production-ready, and enterprise-grade MySQL alternative.

During support work, one of the most common issues we see is: “I try to connect to MySQL and get a 1045 error,” often followed by “but I’m sure my user and password are correct.” This post outlines other common causes.
|
1 2 |
[engineer@percona]# mysql -u root -psekret ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) |
If no host is specified, MySQL connects to localhost by default.
Fix:
|
1 |
mysql -u root -psekret -h <IP> -P 3306 |
|
1 2 |
mysql -u nonexistant -psekret -h localhost ERROR 1045 (28000) |
Fix: Check and create user if needed:
|
1 |
SELECT User FROM mysql.user WHERE User='nonexistant'; |
|
1 |
CREATE USER 'nonexistant'@'localhost' IDENTIFIED BY 'sekret'; |
|
1 |
SELECT Host, User FROM mysql.user WHERE User='nonexistant'; |
Check client IP:
|
1 |
ip address | grep inet | grep -v inet6 |
|
1 |
dig +short myip.opendns.com @resolver1.opendns.com |
Fix:
|
1 |
CREATE USER 'nonexistant'@'%' IDENTIFIED BY 'sekret'; |
|
1 |
SELECT Host, User, authentication_string FROM mysql.user WHERE User='nonexistant'; |
Fix: Reset password:
|
1 |
SET PASSWORD FOR 'nonexistant'@'%' = 'hello$!world'; |
|
1 |
mysql -u nonexistant -phello$!world |
Fix:
|
1 |
mysql -u nonexistant -p'hello$!world' |
|
1 |
ALTER USER 'ssluser'@'%' REQUIRE SSL; |
Fix:
|
1 |
mysql -u ssluser -psekret --ssl-mode=REQUIRED |
More info:
|
1 |
CREATE USER 'ap_user'@'%' IDENTIFIED WITH auth_pam; |
Fix: Verify system user:
|
1 |
cat /etc/passwd | grep ap_user |
Reset password:
|
1 |
sudo passwd ap_user |
skip-grant-tables to my.cnfFLUSH PRIVILEGES;skip-grant-tablesYou should now be able to log in normally.