Unable to login to MySQL as root

massideux :

I have completely locked myself out from MySQL.

The solutions I find out there suggests to run sudo mysql -u root which used to work but I can't even login that way.

Error: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I tried to reinstall MySQL but that didn't help either since I am still being prompted for a password, how is this even possible?

Anyone has experience with this?

Solution When I uninstalled the software I didn't do all the necessary steps, I followed this guide in order to re-install it and I now have access again!

symcbean :

The syntax you are using assumes that there is no root password set. The error messages shows that there is a password set. Berto99's answer shows you how to get the system to prompt for a password. Note that this "root" account is not the same as a "root" account configured on your host - but may have been configured to use the same password.

If you don't know what that password is, you can force the system to change it by starting the mysql service with an init script which changes the password e.g.

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=14004&siteId=1