Are you getting the following error when trying to login to the MySQL root on an Ubuntu system or other Linux distribution? We’ll show you how to clear it up in a matter of seconds.
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
This error is caused by the auth_socket plugin. The simplest solution is to just disable the plugin. Here are the commands to do it:
1. Login to MySQL as root (sudo will bypass password prompt)
$ sudo mysql -u root
2. Change to the mysql
database and set the plugin to mysql_native_password
for the root user.
mysql> USE mysql; mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root'; mysql> FLUSH PRIVILEGES;
3. You have to change the root password for this to work. Even just specifying the current password is fine too, but this command must be executed:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password_here'; mysql> exit;
4. Lastly, restart MySQL for the changes to take effect.
$ sudo systemctl restart mysql
5. You can now login to MySQL root as normal, and will no longer encounter the error.
$ mysql -u root -p
Thank you it worked for me logging into mysql workbench on linux mint 21
Thank you very much.
Thank you, this worked for me using Ubuntu 22.04 and I was able to login to my mysql-workbench-community too.
Thank you very much
It worked for me, thank you!
That was LIFE SAVING!!! THANKS! I was about to jump out of the window because of this problem …
Thank you x 1,000,000…I would have been banging my head against the wall for hours had I not come across your post! TY TY TY TY TY!!!