MySQL – Error 1045 (28000) using password: YES

Alright, I don’t know what happened when trying to login MySQL. And it shows that message: MySQL – Error 1045 (28000) using password: YES. I am pretty sure that user/pwd pair is correct.

After searching and studying some articles and forum discussions. I found it might be caused by broken SQL or reinstall SQL. But I can’t remember I had done that before.

 

So, I just recap how to restore your SQL here.

// first, stop your SQL daemon
$sudo service mysql stop

After stopping your SQL daemon, then we need to start SQL without grant table.

$sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

After that, login your SQL as root.

$sudo mysql -uroot mysql -p

We need to reset root pwd now.

$mysql> UPDATE user SET Password=PASSWORD('new root pwd') where USER='root';

Let root regain the access right for all of your databases.

$mysql> GRANT all ON *.* TO root@'localhost' IDENTIFIED BY 'new root pwd';

Update permission & exit SQL

$mysql> flush privileges;
$mysql> quit;

Relogin to your SQL

$sudo mysql -uroot mysql -p

I beleive you now can use your root pwd to login SQL, but you still can’t login, keep going through followed steps.

If you will need to see following code, that means you’re not lucky enough (‘.’)
You need to check /etc/mysql/debian.cnf file in your system.
And find [client] section.
Use this account to login.

$sudo mysql -udebian-sys-maint -p

Input debian-sys-maint pwd. and repeat these steps.

We need to reset root pwd now.

$mysql> UPDATE user SET Password=PASSWORD('new root pwd') where USER='root';

Let root regain the access right for all of your databases.

$mysql> GRANT all ON *.* TO root@'localhost' IDENTIFIED BY 'new root pwd';

Update permission & exit SQL

$mysql> flush privileges;
$mysql> quit;

Relogin to your SQL

$sudo mysql -uroot mysql -p

[Reference]
1. https://forums.freebsd.org/threads/55225/
2. http://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y
3. https://www.digitalocean.com/community/questions/setup-mysql-on-ubuntu-droplet-getting-error-error-1045-28000-access-denied-for-user-root-localhost-using-password-yes

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s