Access denied for user 'root'@'localhost'问题的解决

时间:2021-02-06 08:11:01

出现这个问题主要是用户忘记了密码,解决办法如下:

cmd  ->mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD('******') where USER='root';
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye