[解决] Mysql Error Code: 1044. Access denied for user ‘root’ database ***

root身份登录,反而报错:

Access denied for user 'root'@'%' to database '***' ErrorCode: 1044

神奇了~

mysql>SELECT host,user,password(mysql5.7版本请去掉password字段,否则会报错),Grant_priv,Super_priv FROM mysql.user;

+-----------+---------------+------------+------------+

| host | user | Grant_priv | Super_priv |

+-----------+---------------+------------+------------+

| localhost | root    | N     | Y |

| %         | root    | N     | Y |

| 127.0.0.1 | root    | N     | Y |

| localhost | mysql.session | N | Y |

| localhost | mysql.sys | N   | N |

+-----------+---------------+------------+------------+

5 rows in set (0.00 sec)

可以看到root的Grant_priv未打开。。。

mysql> UPDATE mysql.user SET Grant_priv=’Y’, Super_priv=’Y’ WHERE User=’root’;

Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

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

再检查下是否执行成功。

mysql> SELECT host,user,Grant_priv,Super_priv FROM mysql.user;

mysql> \q
Bye

重新登录再测试下,必要的话restart下mysql~

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据