mysql ERROR 1356 (HY000) error handling

When you want to query the relevant view information under sys, the following error is reported:

[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

Reason: Stored Routines under SYS are lost. It may be that Stored Routines are not backed up when mysqldump is used to backup all databases (–all-databases), or they are deleted during recovery.
Query the number of Stored Routines under the sys library through the following statement, and see that the number is 0

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

To restore:
Just call mysql_upgrade, and mysql_upgrade will check the data dictionary, if problems are found and repaired.

[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 ~]# 

Then execute the above error statement again, and it can be executed normally.

[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)

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish