I have a view defined in a MySQL 5.0 database as:
CREATE OR REPLACE ALGORITHM=MERGE
DEFINER=db1_user@'%' SQL SECURITY DEFINER
VIEW db2.data_view AS SELECT * FROM db1.data_table;
This is done to give users of db2 access to this single table in db1, and works for SELECT queries:
[db2_user@db2]> select name from data_view limit 1;
+----------------+
| name |
+----------------+
| slartibartfast |
+----------------+
1 row in set (0.00 sec)
However, when I try and explain the same query, I get:
[db2_user@db2]> explain select name from data_view limit 1;
ERROR 1345 (HY000): EXPLAIN/SHOW can not be issued; lacking privileges for
underlying table
I granted the db2 user the SHOW VIEW
privilege for the view, but I get the same error for EXPLAIN
.
GRANT SHOW VIEW ON `db2`.`data_view` TO 'db2_user'@'%';
What is required to allow users with access to the view to run EXPLAIN
on it?