菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
352
0

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'

原创
05/13 14:22
阅读数 75872

在处理这个问题(https://www.cnblogs.com/abclife/p/11038660.html)的时候,开发同学在最后修改视图的definer的时候又遇到了以下的报错信息:

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'

 

数据库版本是:mysql 5.7.25。让他执行以下操作:

>select user();
>select current_user() from dual;
>select host,user from mysql.user where user='root';

>show grants for root@'localhost';
>show grants for root@'%';

>select * from mysql.user where user='root';

  

反馈说用户和权限都没啥问题,然后再次让其把执行报错的现象截图发过来:

root@localhost:information_schema 11:16:24>alter definer=`root`@`%` view <view_name> as select  ...
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'

 

可以看到,它是在information_schema数据库下执行,切换到视图真正所在的数据库再次执行命令就可以正确执行了。 

 

 因为information_schema是一个虚拟的数据库,里面的表其实都是视图。其实在导入数据的时候,也没有必要将information_schema导一遍 。 

 

发表评论

0/200
352 点赞
0 评论
收藏