MySQL错误:Access denied for user 'root'@'%' to database 'mytest'
程序员文章站
2024-03-14 16:57:34
...
一、错误描述
最近在使用MySQL时创建好了数据库(gateway),用户(gateway),使用root用户在赋予新建用户gateway权限的时候执行如下命令:
GRANT ALL on gateway.* to 'gateway'@'%' identified by 'gateway' with grant option;
但却报了一个错误
Access denied for user 'root'@'%' to database 'gateway'
试了好多办法,最后解决了,现分享给大家
二、解决方法
最后发现是user表中’root’@’%’没有grant的权限
可以用如下命令查看:
可以看到现在这两个权限都是N
然后我们更新它们为Y,然后重启mysql
update mysql.user set Grant_priv='Y',Super_priv='Y' where user = 'root' and host = '%';
flush privileges;
重启mysql,必须要重启的哈
然后此时再执行grant语句就可以成功了
以上是使用的Navicat客户端,其他数据库客户端,或者直接登录mysql服务器执行命令行都一样的。
谢谢观看!
推荐阅读
-
MySQL错误:Access denied for user 'root'@'%' to database 'mytest'
-
Access denied for user 'root'@'localhost' to database 'information_schema'
-
mysql Access denied for user ‘root’@’localhost’ (using password: YES)解决方法
-
mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database
-
mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database
-
MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passw
-
MySQL: ERROR 1044 (42000) Access denied for user ''@'localhost' to database 'aliendatabase'
-
MySQL: ERROR 1044 (42000) Access denied for user ''@'localhost' to database 'aliendatabase'
-
MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passw
-
[转载]解决mysql“Access denied for user 'root_MySQL