暂无图片
暂无图片
8
暂无图片
暂无图片
暂无图片

mysql ERROR 1356 (HY000) 错误处理

原创 谢辉元 2020-10-08
9931

当要查询sys下相关视图信息时报错如下:

[root@mysql.sock][sys]>>select thd_id, conn_id, thread_os_id, name from sys.processlist a ,
    -> performance_schema.threads b where a.thd_id =b.thread_id and
    -> conn_id >0;
ERROR 1356 (HY000): View 'sys.processlist' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
[root@mysql.sock][sys]>>desc processlist;
ERROR 1356 (HY000): View 'sys.processlist' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

原因:SYS 下Stored Routines发生丢失,可能是使用mysqldump在做所有库(–all-databases)备份时Stored Routines没有备份,或者恢复时被删除了。
通过如下语句查询sys库下Stored Routines数量,看到数量为0

[root@mysql.sock][sys]>>select count(*) from information_schema.ROUTINES where ROUTINE_SCHEMA='sys';
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

进行恢复:
调用mysql_upgrade即可,mysql_upgrade将对数据字典进行检查,如发现问题并进行修复。

[root@ora11g1 ~]# mysql_upgrade -S /u01/mysql/mysql3306/run/mysql.sock -p123456
mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
The sys schema is already up to date (version 1.5.1).
Found 0 sys functions, but expected 22. Re-installing the sys schema.   
--注意这行提示期望sys下有22个函数,但发现只有0个,将进行重建。
Upgrading the sys schema.
Checking databases.
。。。
Upgrade process completed successfully.
Checking if update is needed.
[root@ora11g1 ~]# 

然后再次执行上述报错语句,已经可以正常执行了

[root@mysql.sock][sys]>>select thd_id, conn_id, thread_os_id, name from sys.processlist a ,
    -> performance_schema.threads b where a.thd_id =b.thread_id and
    -> conn_id >0;
+--------+---------+--------------+--------------------------------+
| thd_id | conn_id | thread_os_id | name                           |
+--------+---------+--------------+--------------------------------+
|     50 |       1 |         6072 | thread/sql/event_scheduler     |
|     51 |       2 |         6074 | thread/sql/compress_gtid_table |
|     53 |       4 |         6087 | thread/sql/one_connection      |
|     54 |       5 |         8210 | thread/sql/one_connection      |
|     55 |       6 |         8211 | thread/sql/one_connection      |
+--------+---------+--------------+--------------------------------+
5 rows in set (0.15 sec)
[root@mysql.sock][sys]>>select count(*) from information_schema.ROUTINES where ROUTINE_SCHEMA='sys';
+----------+
| count(*) |
+----------+
|       48 |
+----------+
1 row in set (0.00 sec)
最后修改时间:2021-06-24 22:47:50
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论