0

I try to access MySQL but I can't. I wrote skip-grant-tables in the mysql configuration and restart it but it still doesn't work.

$ mysql -u root -p 
ENTER PASSWORD: *****
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I also try to connect phpmyadmin but I can't

Cannot log in to the MySQL server 

and

mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
  • is it a fresh installation? 1. https://forums.mysql.com/read.php?11,34014,46593 2. https://dba.stackexchange.com/questions/38803/mysql-error-1045-28000-access-denied-for-user – Abhilash PS Jun 30 '20 at 13:20
  • Does this answer your question? [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – Sowjanya R Bhat Jun 30 '20 at 19:19
  • Are you trying to connect through phpMyAdmin with skip-grant-tables running? That isn't recommended (or tested, for that matter); you should correct the password then restart MySQL normally, then connect with phpMyAdmin. – Isaac Bennetch Jul 01 '20 at 02:13
  • No. I try what is on the:https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw but I still not work – Andrei Cocota Jul 01 '20 at 09:08

1 Answers1

0

Error meaning:

SQLSTATE[28000] [1045] Access denied for user 'user'@'localhost' (using password: YES)

Possibilities:

  1. Typo in password
  2. Accessing from the wrong host
  3. User doesn’t exist

But in your scenario, I don't see a chance for case 3. But cases 1 and 2 are possible.

Can you check if your password is correct, i,e. no typo in your password.

If you have a wrong password you can reset the admin/root password by starting the MySQL in safe mode.


UPDATE user SET password=PASSWORD("new_password") WHERE User='root';

In the second case, the reason is MySQL allows user access only from hosts defined in the MySQL user table.

it can be resolved by starting the MySQL in safe mode and


UPDATE user SET host='hostname' WHERE user='username';

Abhilash PS
  • 734
  • 1
  • 11
  • 25