Bootstrap FreeKB - mySQL / MariaDB - Resolve "1045 (28000): Access denied for user using password: YES"
mySQL / MariaDB - Resolve "1045 (28000): Access denied for user using password: YES"

Updated:   |  mySQL / MariaDB articles

Let's say your mySQL or MariaDB error log contains the following warning.

Access denied for user 'john.doe'@'server1.example.com' (using password: YES)

 

Notice in this example that access is denied for user john.doe. This assume you are able to log into your MariaDB or mySQL server. If you have root access to mySQL or MariaDB, ensure John Doe's user account exists. 

~]# mysql -u root --password=itsasecret "select User,Password,Host from mysql.user where User = 'john.doe'\G"

 

Or, if you have configured passwordless authentication the -e command line option can be used.

~]# mysql -e "select User,Password,Host from mysql.user where User = 'john.doe'\G"

 

Notice in this example that access is denied for user john.doe. Notice in this example that john.doe has access to host %. The % character means that john.doe is allowed to make remote connections to mySQL or MariaDB.

~]# mysql -e "select User,Password,Host from mysql.user where User = 'john.doe'\G"
*************************** 1. row ***************************
User: john.doe
Password: *964A30F03EBE2D0D8EADC172640E4389BC9AF7FF
Host: %

 

Notice that the hashed password in this example is 964A30F03EBE2D0D8EADC172640E4389BC9AF7FF. If you know what the user's password is supposed to be, the select password command can be used to verify the users password matches the hashed password.

~]# mysql -e "select password('itsasecret')"
+-------------------------------------------+
| password('itsasecret')                    |
+-------------------------------------------+
| *964A30F03EBE2D0D8EADC172640E4389BC9AF7FF |
+-------------------------------------------+

 

If the password is incorrect, you can updated the password.

mysql -e "update mysql.user SET Password=PASSWORD('itsasecret') where User='john.doe'"
mysql -e "update mysql.user SET authentication_string=PASSWORD('itsasecret') where User='john.doe'"

 

Or like this if using a more recent version of MariaDB.

SET PASSWORD for 'john.doe'@'%' = PASSWORD('itsasecret');

 

And then flush privileges.

mysql -e "FLUSH PRIVILEGES"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter aee10b in the box below so that we can be sure you are a human.