MySQL Access denied for user ‘root’@’localhost’问题解决

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hongweigg/article/details/86648001

问题:

MySQL在使用过程中,使用JDBC连接时,报: Access denied for user ‘root’@’localhost’异常。

解决:

1、进入MySQL安装目录,执行命令:

mysql -u root

2、授权

grant all privileges on *.* to 'root'@'localhost';

3、刷新

flush privileges;

命令执行示例:

E:\mysql-5.6.25-winx64\bin>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.6.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant all privileges on *.* to 'root'@'localhost';
Query OK, 0 rows affected (0.21 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.19 sec)

猜你喜欢

转载自blog.csdn.net/hongweigg/article/details/86648001
今日推荐