I have installed mariadb and when as a Linux root user, I can run mysql command to access the database. But when I try to login as a normal Linux user and run mysql -u root -p, I am getting error:

ERROR 1698 (28000): Access denied for user 'root'@'localhost'. 

I tried several methods like reset password for the mysql root user, but no use.

Any help will be great.


I had the same problem, it was caused by a "plugin" value in "mysql.user" table.

Have you tried with this answer: https://askubuntu.com/a/636579/299538

Here is an explanation for that: https://superuser.com/a/1071043/592085


In MariaDB you cannot login with normal user, you must root access or use sudo. Another solution add another root user with full privileges.

Connect with sudo to db:

sudo mysql -u root

Check your account in present db:

mysql> SELECT User,Host FROM mysql.user;
| User             | Host      |
| root             | localhost |

Recreate user root (use password if you need):

mysql> CREATE USER 'root'@'%' IDENTIFIED BY '';

Give permission:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';



Show database uses:

SELECT User,Host FROM mysql.user;
| User | Host      |
| root | %         |
| root | localhost |

Exit and connect with normal user:

mysql -u root

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.