[Solved] ERROR 1698 (28000) Access denied for user ‘root’@’localhost’

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';

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

7 thoughts on “[Solved] ERROR 1698 (28000) Access denied for user ‘root’@’localhost’”

  1. 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!!!

Leave a Comment

Your email address will not be published. Required fields are marked *