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

后端 未结 17 1747
执笔经年
执笔经年 2020-11-22 10:00

I\'m setting up a new server and keep running into this problem.

When I try to login to the MySQL database with the root user, I get the error:

17条回答
  •  悲&欢浪女
    2020-11-22 10:59

    in my case,

    dev@Dev-007:~$ mysql -u root -p
    Enter password: 
    ERROR 1698 (28000): Access denied for user 'root'@'localhost'
    

    I am sure my password was correct otherwise error code would be ERROR 1045 (28000): Access denied for user

    so i relogin using sudo,

    dev@Dev-007:~$ sudo mysql -u root -p
    

    this time it worked for me . see the docs

    and then change root password,

    mysql> alter user 'root'@'%' identified with mysql_native_password by 'me123';
    Query OK, 0 rows affected (0.14 sec)
    
    mysql> 
    

    then restart server using sudo /etc/init.d/mysql restart

提交回复
热议问题