Connection to Cloud SQL for MySQL fails intermittently

Hi there,

I connect to my Cloud SQL instance (Mysql 8.0.26) and query data from views, but the connection fails intermittently (about once in 10 queries). The error message is: “EXPLAIN/SHOW can not be issued; lacking privileges for underlying table”.

This mysql user has granted SELECT, SHOW VIEW and did flush privileges;.

The same issue happened to read replica instance too.

Has anybody experienced the same problem?

The error message “EXPLAIN/SHOW can not be issued; lacking privileges for underlying table” indicates that the MySQL user does not have the necessary privileges to execute the EXPLAIN or SHOW statements on the underlying tables of the views. These statements are required to generate the execution plans for the queries, which is why the queries are failing intermittently.

To resolve the privilege issue, ensure the MySQL user has SELECT privileges on all underlying tables of the views. Execute the GRANT SELECT statement for each underlying table or use a wildcard if appropriate. If the error persists after confirming the privileges, investigate other potential causes such as network issues or Cloud SQL Proxy configurations.