一、ERROR 1054 (42S22)
Unknown column 'password_last_changed' in 'mysql.user'
mysql5.6 升级为 5.7 遇到在授权用户时报错:
ERROR 1054 (42S22): Unknown column 'password_last_changed' in 'mysql.user' |
---|
字段 ’password_last_changed’ 在 MySQL <5.7 的版本中存在, 但是在 5.7,给删除了。
所以升级了 mysql server 之后,你还有运行 ’mysql_upgrade’ 脚本把 tables 从老版本中迁移到新版本。
解决方法:
# /data/mysql-5.7.16/bin/mysql_upgrade -uroot -pIp02016@mlS7639 -h127.0.0.1 -P3215 |
---|
但是会报错:
mysql_upgrade失败是因为以下表不存在, Checking if update is needed. |
---|
mysql_upgrade: [ERROR] 1146: Table 'mysql.innodb_table_stats' doesn't exist ...... |
解决方法:
mysql> use mysql; # 一定要是 drop table if exists
mysql> drop table if exists mysql.innodb_index_stats; drop table if exists mysql.innodb_table_stats; drop table if exists mysql.slave_master_info; drop table if exists mysql.slave_relay_log_info; drop table if exists mysql.slave_worker_info;drop table if exists mysql.gtid_executed;drop table if exists mysql.engine_cost;drop table if exists mysql.help_topic;drop table if exists mysql.help_relation;drop table if exists mysql.help_keyword;drop table if exists mysql.help_category;drop table if exists mysql.plugin;drop table if exists mysql.servers;drop table if exists mysql.server_cost;drop table if exists mysql.time_zone;drop table if exists mysql.time_zone_leap_second;drop table if exists mysql.time_zone_name;drop table if exists mysql.time_zone_transition;drop table if exists mysql.time_zone_transition_type;drop table if exists mysql.ndb_binlog_index;drop table if exists sys.sys_config;
# 接下来,并进入到数据库数据文件所在目录,删除表所对应的idb文件
# cd /data/mysql5.7.16data/mysql3215/data/mysql |
---|
# ll innodb_* # ll ndb_binlog_index.* |
# cd ../sys # ll sys_config* |
mysql> source /data/mysql-5.7.16/share/mysql_system_tables.sql
最后:
# /data/mysql-5.7.16/bin/mysql_upgrade -uxxxx -pxxxx -h127.0.0.1 -Pxxxx ...... Upgrade process completed successfully. |
---|
二、ERROR 1682 (HY000)
Native table 'performance_schema'.'session_variables' has the wrong structure
mysql 5.6 升级到 mysql5.7 查看参数报错:
mysql> show variables like '%read_only%';
ERROR 1682 (HY000): Native table 'performance_schema'.'session_variables' has the wrong structure
报错原因:从 mysql5.7.6 开始 information_schema.global_status 已经开始被舍弃,为了兼容性,此时需要打开 show_compatibility_56
解决办法:set @@global.show_compatibility_56=ON;
mysql> set @@global.show_compatibility_56=ON;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%read_only%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| innodb_read_only | OFF |
| read_only | ON |
| super_read_only | OFF |
| tx_read_only | OFF |
+------------------+-------+
4 rows in set (0.00 sec)