mysql root用户没有grant权限
2022-03-01 21:31 abce 阅读(3047) 评论(0) 编辑 收藏 举报最近接手了几个库,root用户都没有grant权限。
1.root用户登录后没有授权的权限
1 2 | mysql> grant insert on mysql.abce to 'myabc' @ '127.0.0.1' ; ERROR 1142 (42000): GRANT command denied to user 'root' @ 'H.hostname.com' for table 'abce' |
2.查看用户的权限
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | mysql> show grants for root@ '%' ; + -------------------------------------------+ | Grants for root@% | + -------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root' @ '%' | + -------------------------------------------+ 1 row in set (0.00 sec) mysql> select host, user ,Grant_priv from mysql. user where user = 'root' ; + ------+------+------------+ | host | user | Grant_priv | + ------+------+------------+ | % | root | N | + ------+------+------------+ 1 row in set (0.00 sec) mysql> |
常规情况下,root的权限是:
1 2 3 4 5 6 7 | mysql> show grants for root@ 'localhost' ; + ---------------------------------------------------------------------+ | Grants for root@localhost | + ---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root' @ 'localhost' WITH GRANT OPTION | | GRANT PROXY ON '' @ '' TO 'root' @ 'localhost' WITH GRANT OPTION | + ---------------------------------------------------------------------+ |
为了省事,修改了一下表:添加权限
1 2 3 4 5 6 7 8 9 | mysql> update mysql. user set Grant_priv= "Y" where user = "root" and host= "%" ; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> commit ; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges ; Query OK, 0 rows affected (0.00 sec) |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)