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

后端 未结 17 1591
执笔经年
执笔经年 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:58

    No need of sudo

    The database is initialised with 2 all-privilege accounts: the first one is "root" which is inaccessible and the second one with your user name (check with command whoami).

    To enable access to root account, you need to login with your user name

    mysql -u $(whoami)
    

    and manually change password for root

    use mysql;
    set password for 'root'@'localhost' = password('YOUR_ROOT_PASSWORD_HERE');
    flush privileges;
    quit
    

    Login as 'root'

    mysql -u root -p
    

提交回复
热议问题