MySQL 从5.5.20 升级到5.6.21 启动后报如下错误:
[ERROR] Column count of mysql.threads is wrong. Expected 14, found 3. Created with MySQL 50520, now running 50621. Please use mysql_upgrade to fix this error.
注意这里是报的错是mysql库中的threads 表,实际上mysql库中是没有这张表的。这张表存在于performance_schema中。
当去访问performance_schema中的threads表时,又出如下错误。
ERROR 1682 (HY000): Native table 'performance_schema'.'threads' has the wrong structure
mysql> select version();
+-------------------------------------------+
| version() |
+-------------------------------------------+
| 5.6.21-enterprise-commercial-advanced-log |
+-------------------------------------------+
1 row in set (0.00 sec)
mysql> use performance_schema
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
mysql> select * from threads;
ERROR 1682 (HY000): Native table 'performance_schema'.'threads' has the wrong structure
原因在于升级的时候,这张表没升成功。
删除threads表,重建theads表,重启MySql,问题解决。
mysql> drop table threads;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE `threads` (
-> `THREAD_ID` bigint(20) unsigned NOT NULL,
-> `NAME` varchar(128) NOT NULL,
-> `TYPE` varchar(10) NOT NULL,
-> `PROCESSLIST_ID` bigint(20) unsigned DEFAULT NULL,
-> `PROCESSLIST_USER` varchar(16) DEFAULT NULL,
-> `PROCESSLIST_HOST` varchar(60) DEFAULT NULL,
-> `PROCESSLIST_DB` varchar(64) DEFAULT NULL,
-> `PROCESSLIST_COMMAND` varchar(16) DEFAULT NULL,
-> `PROCESSLIST_TIME` bigint(20) DEFAULT NULL,
-> `PROCESSLIST_STATE` varchar(64) DEFAULT NULL,
-> `PROCESSLIST_INFO` longtext,
-> `PARENT_THREAD_ID` bigint(20) unsigned DEFAULT NULL,
-> `ROLE` varchar(64) DEFAULT NULL,
-> `INSTRUMENTED` enum('YES','NO') NOT NULL
-> ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.00 sec)