查询mysql.tidb_mdl_view报错了

【 TiDB 使用环境】测试
【 TiDB 版本】 8.0.11-TiDB-v8.1.0
【复现路径】做过哪些操作出现的问题
【遇到的问题:问题现象及影响】
【资源配置】进入到 TiDB Dashboard -集群信息 (Cluster Info) -主机(Hosts) 截图此页面
【附件:截图/日志/监控】
刚初始化安装的tidb v8.1.0,通过tiup cluster display 集群名字看到的状态都是正常的,连接到tidb server执行以下语句报错了:
mysql> select * from mysql.tidb_mdl_view;
ERROR 1356 (HY000): View ‘mysql.tidb_mdl_view’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

mysql.tidb_mdl_view视图的创建语句以及该视图涉及的对象的视图如下所示:
CREATE ALGORITHM=UNDEFINED DEFINER=@ SQL SECURITY DEFINER VIEW tidb_mdl_view (job_id, db_name, table_name, query, session_id, start_time, SQL_DIGESTS) AS (SELECT tidb_mdl_info.job_id AS job_id,JSON_UNQUOTE(JSON_EXTRACT(CAST(CAST(job_meta AS CHAR) AS JSON), _UTF8MB4’$.schema_name’)) AS db_name,JSON_UNQUOTE(JSON_EXTRACT(CAST(CAST(job_meta AS CHAR) AS JSON), _UTF8MB4’$.table_name’)) AS table_name,JSON_UNQUOTE(JSON_EXTRACT(CAST(CAST(job_meta AS CHAR) AS JSON), _UTF8MB4’$.query’)) AS query,session_id AS session_id,cluster_tidb_trx.start_time AS start_time,TIDB_DECODE_SQL_DIGESTS(all_sql_digests, 4096) AS SQL_DIGESTS FROM ((mysql.tidb_ddl_job) JOIN mysql.tidb_mdl_info) JOIN information_schema.cluster_tidb_trx WHERE tidb_ddl_job.job_id=tidb_mdl_info.job_id AND CONCAT(_UTF8MB4’,‘, tidb_mdl_info.table_ids, _UTF8MB4’,‘) REGEXP CONCAT(_UTF8MB4’,(‘, REPLACE(cluster_tidb_trx.related_table_ids, _UTF8MB4’,‘, _UTF8MB4’|‘), _UTF8MB4’),')!=0)

CREATE TABLE tidb_mdl_info (
job_id bigint(20) NOT NULL,
version bigint(20) NOT NULL,
table_ids mediumtext DEFAULT NULL,
owner_id varchar(64) NOT NULL DEFAULT ‘’,
PRIMARY KEY (job_id) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

CREATE TABLE CLUSTER_TIDB_TRX (
INSTANCE varchar(64) DEFAULT NULL,
ID bigint(21) unsigned NOT NULL,
START_TIME timestamp(6) NULL DEFAULT NULL COMMENT ‘Start time of the transaction’,
CURRENT_SQL_DIGEST varchar(64) DEFAULT NULL COMMENT ‘Digest of the sql the transaction are currently running’,
CURRENT_SQL_DIGEST_TEXT text DEFAULT NULL COMMENT ‘The normalized sql the transaction are currently running’,
STATE enum(‘Idle’,‘Running’,‘LockWaiting’,‘Committing’,‘RollingBack’) DEFAULT NULL COMMENT ‘Current running state of the transaction’,
WAITING_START_TIME timestamp(6) NULL DEFAULT NULL COMMENT ‘Current lock waiting’‘s start time’,
MEM_BUFFER_KEYS bigint(64) DEFAULT NULL COMMENT ‘How many entries are in MemDB’,
MEM_BUFFER_BYTES bigint(64) DEFAULT NULL COMMENT ‘MemDB used memory’,
SESSION_ID bigint(21) unsigned DEFAULT NULL COMMENT ‘Which session this transaction belongs to’,
USER varchar(16) DEFAULT NULL COMMENT ‘The user who open this session’,
DB varchar(64) DEFAULT NULL COMMENT ‘The schema this transaction works on’,
ALL_SQL_DIGESTS text DEFAULT NULL COMMENT ‘A list of the digests of SQL statements that the transaction has executed’,
RELATED_TABLE_IDS text DEFAULT NULL COMMENT ‘A list of the table IDs that the transaction has accessed’,
WAITING_TIME double DEFAULT NULL COMMENT ‘Current lock waiting time’
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

什么用户执行的,是不是权限不够?

是root用户执行的:

mysql> show grants;
±------------------------------------------------------------+
| Grants for User |
±------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ WITH GRANT OPTION |
±------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from tidb_mdl_view;
ERROR 1356 (HY000): View ‘mysql.tidb_mdl_view’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
mysql>

bug
https://github.com/pingcap/tidb/issues/53292

2 个赞

此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。