5

I am getting below error while logged into the phpmyadmin.

it is not a fresh installation.

I have also tried login through the command line.

1.

mysql -u root -p

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

2.

sudo mysql -u root -p

I am successfully login into mysql using above command.

but not with case 1.

Mysql details:
username : root 
password : 
5

This is because MySQL by default use local system account to login as user root. This is done with plugin “unix_socket” or it might possible that password has been changed.

To allow MySQL user root to login to PhpMyAdmin, run following commands in MySQL command prompt

use mysql;
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
FLUSH PRIVILEGES;
exit;

see PhpMyAdmin

3

step 1. sudo mysql -u root -p

step 2. USE mysql;

step 3. ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';

Here 'admin' is your new password, yo can change it.

step 4. exit Thanks. You are done.

2

I solved the above problem with setting the plugin value in user tables

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart
  • And how did you log in mysql to use the command USE mysql? This is catch 22. – Hrvoje T May 28 '18 at 13:01
  • using this command sudo mysql -u root -p – prashanth padala May 28 '18 at 15:46

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