MySQL - Error 1045 (28000)

mysql-logo.jpg?w=2924

What happened?

Alright, I don’t know what happened when trying to log in to 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. The interesting is I can’t remember I had done that before.

How to solve it?

So, here some steps show how to restore your SQL.

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

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

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

After that, log in your SQL as root.

1
$sudo mysql -uroot mysql -p

We need to reset root pwd now.

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

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

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

Update the permission & exit SQL

1
2
$mysql> flush privileges;
$mysql> quit;

Re-login to your SQL

1
$sudo mysql -uroot mysql -p

If it still doesn’t work!

I believe you can use your root PWD to log in to MySQL now, but if you still can’t login, keep going through the following steps. Sorry for your back luck. You need to check /etc/mysql/debian.cnf file in your system and find [client] section. Use this account to log in.

1
$sudo mysql -udebian-sys-maint -p

Input debian-sys-maint PWD. and repeat these steps. We need to reset root pwd now.

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

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

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

Update the permission & exit SQL

1
2
$mysql> flush privileges;
$mysql> quit;

Re-login to your SQL

1
$sudo mysql -uroot mysql -p

[Reference]

  1. mysql ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO) | The FreeBSD Forums
  2. mysql - ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES) - Stack Overflow
  3. Setup MySQL on Ubuntu Droplet getting error ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES) | DigitalOcean

MySQL - Error 1045 (28000)

mysql-logo.jpg?w=2924

What happened?

Alright, I don’t know what happened when trying to log in to 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. The interesting is I can’t remember I had done that before.

How to solve it?

So, here some steps show how to restore your SQL.

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

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

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

After that, log in your SQL as root.

1
$sudo mysql -uroot mysql -p

We need to reset root pwd now.

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

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

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

Update the permission & exit SQL

1
2
$mysql> flush privileges;
$mysql> quit;

Re-login to your SQL

1
$sudo mysql -uroot mysql -p

If it still doesn’t work!

I believe you can use your root PWD to log in to MySQL now, but if you still can’t login, keep going through the following steps. Sorry for your back luck. You need to check /etc/mysql/debian.cnf file in your system and find [client] section. Use this account to log in.

1
$sudo mysql -udebian-sys-maint -p

Input debian-sys-maint PWD. and repeat these steps. We need to reset root pwd now.

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

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

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

Update the permission & exit SQL

1
2
$mysql> flush privileges;
$mysql> quit;

Re-login to your SQL

1
$sudo mysql -uroot mysql -p

[Reference]

  1. mysql ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO) | The FreeBSD Forums
  2. mysql - ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES) - Stack Overflow
  3. Setup MySQL on Ubuntu Droplet getting error ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES) | DigitalOcean