1、设置参数
set global variables innodb_fast_shutdown = 0;
2、关闭mysql服务器
mysqladmin -uroot -p -S /tmp/mysql_3303.sock
3、下载5.7的安装包并解压
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
tar -xzvf mysql-5.7.22-linux-glibc2.12-x86_64 -C ./
变更配置文件为5.7的配置文件:也可以用之前的配置相关的新参数
############5.7 new parameter settings###################
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=8
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 4
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 1G
innodb_purge_rseg_truncate_frequency = 128
binlog_gtid_simple_recovery=1
log_timestamps=system
transaction_write_set_extraction=MURMUR32
show_compatibility_56=on
secure_file_priv=/tmp/
4、备份之前的安装目录并把新目录指向旧目录
mv mysql56 mysql56bak
ln -s mysql-5.7.22-linux-glibc2.12-x86_64 mysql56 ##(此时的5.6其实是5.7,只是名字上不同)
更改其权限:
chown -R mysql.mysql mysql56
5、启动 并带上--skip-grant-tables 和 --skip-networking
mv mysql56 mysql56bak
ln -s mysql-5.7.22-linux-glibc2.12-x86_64 mysql56 (此时的5.6其实是5.7,只是名字上不同)
可以启动成功,但是错误日志中会存在诸多错误。类似于
2018-05-26T18:20:34.936808+08:00 0 [ERROR] Incorrect definition of table performance_schema.events_stages_summary_by_user_by_event_name: expected column 'USER' at position 0 to have type char(32), found type char(16).
2018-05-26T18:20:34.941411+08:00 0 [ERROR] Column count of performance_schema.events_statements_current is wrong. Expected 41, found 40. Created with MySQL 50640, now running 50722. Please use mysql_upgrade to fix this error.
2018-05-26T18:20:34.942109+08:00 0 [ERROR] Column count of performance_schema.events_statements_history is wrong. Expected 41, found 40. Created with MySQL 50640, now running 50722. Please use mysql_upgrade to fix this error.
2018-05-26T18:20:34.942594+08:00 0 [ERROR] Column count of performance_schema.events_statements_history_long is wrong. Expected 41, found 40. Created with MySQL 50640, now running 50722. Please use mysql_upgrade to fix this error.
2018-05-26T18:20:34.971689+08:00 0 [ERROR] Incorrect definition of table performance_schema.events_statements_summary_by_account_by_event_name: expected column 'USER' at position 0 to have type char(32), found type char(16).
2018-05-26T18:20:34.972213+08:00 0 [ERROR] Incorrect definition of table performance_schema.events_statements_summary_by_user_by_event_name: expected column 'USER' at position 0 to have type char(32), found type char(16).
2018-05-26T18:20:34.973785+08:00 0 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_program' has the wrong structure
2018-05-26T18:20:34.973845+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_current' has the wrong structure
2018-05-26T18:20:34.973874+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_history' has the wrong structure
2018-05-26T18:20:34.973901+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_history_long' has the wrong structure
2018-05-26T18:20:34.973963+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_thread_by_event_name' has the wrong structure
2018-05-26T18:20:34.974002+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_account_by_event_name' has the wrong structure
2018-05-26T18:20:34.974030+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_user_by_event_name' has the wrong structure
2018-05-26T18:20:34.974056+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_host_by_event_name' has the wrong structure
2018-05-26T18:20:34.974087+08:00 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_global_by_event_name' has the wrong structure
2018-05-26T18:20:34.974421+08:00 0 [ERROR] Incorrect definition of table performance_schema.users: expected column 'USER' at position 0 to have type char(32), found type char(16).
2018-05-26T18:20:34.974785+08:00 0 [ERROR] Incorrect definition of table performance_schema.accounts: expected column 'USER' at position 0 to have type char(32), found type char(16).
2018-05-26T18:20:34.992468+08:00 0 [ERROR] Native table 'performance_schema'.'memory_summary_global_by_event_name' has the wrong structure
2018-05-26T18:20:34.992566+08:00 0 [ERROR] Native table 'performance_schema'.'memory_summary_by_account_by_event_name' has the wrong structure
2018-05-26T18:20:34.992627+08:00 0 [ERROR] Native table 'performance_schema'.'memory_summary_by_host_by_event_name' has the wrong structure
2018-05-26T18:20:34.992695+08:00 0 [ERROR] Native table 'performance_schema'.'memory_summary_by_thread_by_event_name' has the wrong structure
2018-05-26T18:20:34.992732+08:00 0 [ERROR] Native table 'performance_schema'.'memory_summary_by_user_by_event_name' has the wrong structure
2018-05-26T18:20:34.992758+08:00 0 [ERROR] Native table 'performance_schema'.'table_handles' has the wrong structure
2018-05-26T18:20:34.992782+08:00 0 [ERROR] Native table 'performance_schema'.'metadata_locks' has the wrong structure
2018-05-26T18:20:34.992811+08:00 0 [ERROR] Native table 'performance_schema'.'replication_connection_configuration' has the wrong structure
2018-05-26T18:20:34.992838+08:00 0 [ERROR] Native table 'performance_schema'.'replication_group_members' has the wrong structure
2018-05-26T18:20:34.992864+08:00 0 [ERROR] Native table 'performance_schema'.'replication_connection_status' has the wrong structure
2018-05-26T18:20:34.992890+08:00 0 [ERROR] Native table 'performance_schema'.'replication_applier_configuration' has the wrong structure
2018-05-26T18:20:34.992919+08:00 0 [ERROR] Native table 'performance_schema'.'replication_applier_status' has the wrong structure
2018-05-26T18:20:34.993008+08:00 0 [ERROR] Native table 'performance_schema'.'replication_applier_status_by_coordinator' has the wrong structure
2018-05-26T18:20:34.993039+08:00 0 [ERROR] Native table 'performance_schema'.'replication_applier_status_by_worker' has the wrong structure
2018-05-26T18:20:34.993064+08:00 0 [ERROR] Native table 'performance_schema'.'replication_group_member_stats' has the wrong structure
2018-05-26T18:20:34.993088+08:00 0 [ERROR] Native table 'performance_schema'.'prepared_statements_instances' has the wrong structure
2018-05-26T18:20:34.993145+08:00 0 [ERROR] Native table 'performance_schema'.'user_variables_by_thread' has the wrong structure
2018-05-26T18:20:34.993181+08:00 0 [ERROR] Native table 'performance_schema'.'status_by_account' has the wrong structure
2018-05-26T18:20:34.993206+08:00 0 [ERROR] Native table 'performance_schema'.'status_by_host' has the wrong structure
2018-05-26T18:20:34.993230+08:00 0 [ERROR] Native table 'performance_schema'.'status_by_thread' has the wrong structure
2018-05-26T18:20:34.993254+08:00 0 [ERROR] Native table 'performance_schema'.'status_by_user' has the wrong structure
2018-05-26T18:20:34.993278+08:00 0 [ERROR] Native table 'performance_schema'.'global_status' has the wrong structure
2018-05-26T18:20:34.993327+08:00 0 [ERROR] Native table 'performance_schema'.'session_status' has the wrong structure
2018-05-26T18:20:34.993363+08:00 0 [ERROR] Native table 'performance_schema'.'variables_by_thread' has the wrong structure
2018-05-26T18:20:34.993388+08:00 0 [ERROR] Native table 'performance_schema'.'global_variables' has the wrong structure
2018-05-26T18:20:34.993412+08:00 0 [ERROR] Native table 'performance_schema'.'session_variables' has the wrong structure
6、升级 系统表数据字典
/usr/local/mysql/bin/mysql_upgrade -uroot -p -S /tmp/mysql_3303.sock
这个命令就相当于登录mysql并操作一些表,所以不需要其他参数,也不需要--defaults-file等启动的参数。
[root@localhost bin]# ./mysql_upgrade -uroot -p -S /tmp/mysql_3303.sock
Enter password:
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
Upgrading the sys schema.
Checking databases.
mysqlslap.t1 OK
sys.sys_config OK
Upgrade process completed successfully.
Checking if update is needed.
当输出最后两行的successfully表示更新成功。
7、关闭并重新启动
shutdown -uroot -p -S /tmp/mysql_3303.sock shutdown
./mysqld_safe --defaults-file=/etc/mysql3303.cnf --user=mysql
8、验证登录
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mysqlslap |
| performance_schema |
| sys |
| test |
| xuning |
+--------------------+
7 rows in set (0.01 sec)
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.22-log |
+------------+
1 row in set (0.00 sec)
升级成功