来自管理员用户:
mysql> GRANT SHOW VIEW ON DBNAME.* to 'user1'@'%';
Query OK, 0 rows affected (0.08 sec)
来自user1:
mysql> show create view instance_information;
ERROR 1142 (42000): SHOW VIEW command denied to user 'user1'@'208.1.1.210' for table 'instance_information'
如果您想知道,instance_information确实是一个视图,如从管理员用户运行时所见:
mysql> show create view instance_information;
+----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View | Create View | character_set_client | collation_connection |
+----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| instance_information | CREATE ALGORITHM=UNDEFINED DEFINER=`chen`@`%` SQL SECURITY DEFINER VIEW `instance_information` AS select `version_build_last`.`Instance_UID` AS `Instance_UID`,`version_build_last`.`Version` AS `Version`,`version_build_last`.`Build` AS `Build`,`insight_connection_last`.`Last_Update` AS `Last_Update_Date`,`instance_device_monitored_count`.`Total_Devices_Monitored` AS `Total_Devices_Monitored` from ((`version_build_last` left join `insight_connection_last` on((`version_build_last`.`Instance_UID` = `insight_connection_last`.`Instance_UID`))) left join `instance_device_monitored_count` on((`version_build_last`.`Instance_UID` = `instance_device_monitored_count`.`Instance_UID`))) | utf8 | utf8_general_ci |
+----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
1 row in set (0.08 sec)
我确实看到了https://bugs.mysql.com/bug.php?id=9506-但这是一个老错误。我们正在使用MySQL的5.6.10版本。