#1698 - Access denied for user 'root'@'localhost' mysql -5.7 and ubuntu-16.04

38,893

Solution 1

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

Solution 2

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

Solution 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.

Share:
38,893

Related videos on Youtube

prashanth padala
Author by

prashanth padala

-Bachelor of Engineering from Mumbai University. Working in a Mumbai based startup as a Web Developer.

Updated on September 18, 2022

Comments

  • prashanth padala
    prashanth padala almost 2 years

    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 : 
    
    • Yaron
      Yaron over 6 years
      this SO Q&A should solve your problem
  • Hrvoje T
    Hrvoje T about 6 years
    And how did you log in mysql to use the command USE mysql? This is catch 22.
  • prashanth padala
    prashanth padala about 6 years
    using this command sudo mysql -u root -p
  • Sudhir Dhumal
    Sudhir Dhumal about 5 years
    Worked for me !!!
  • Maciej Bledkowski
    Maciej Bledkowski almost 3 years
    This helped me <3