MySQL升级从5.6.18到5.7.11
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL升级从5.6.18到5.7.11相关的知识,希望对你有一定的参考价值。
rhel7.2上升级mysql5.6.18到5.7.11
本次使用二进制包采用out-place方式进行升级。
1、备份数据
备份重于一切!
各种备份方法mysqldump、cp.....
2、上传5.7.11软件包并解压
[[email protected] mysql]# ls mysql5.6.18 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz [[email protected] mysql]# tar -zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz ...... [[email protected] mysql]# mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql5.7.11
[[email protected] mysql]# chown mysql:mysql -R mysql5.7.11
[[email protected] mysql]# ls -l
total 8
drwxr-xr-x. 13 mysql mysql 4096 Dec 5 15:17 mysql5.6.18
drwxr-xr-x. 9 mysql mysql 4096 Feb 2 2016 mysql5.7.11
3、停止旧版本数据库
#设置innodb_fast_shutdown=0 [[email protected] bin]# pwd /opt/mysql/mysql5.6.18/bin [[email protected] bin]# ./mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0" Enter password: [[email protected] bin]# ./mysql -u root -p --execute="show global variables like ‘innodb_fast_shutdown‘" Enter password: +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | innodb_fast_shutdown | 0 | +----------------------+-------+ #关闭MySQL [[email protected] bin]# ./mysqladmin -uroot -p shutdown Enter password: [[email protected] bin]# ps -ef |grep mysql root 2771 1575 0 16:58 pts/0 00:00:00 grep --color=auto mysql
innodb_fast_shutdown参数解释参考:http://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_fast_shutdown
4、修改配置文件
#修改/etc/my.cnf文件 [[email protected] bin]# vi /etc/my.cnf basedir = /opt/mysql/mysql5.7.11 #basedir指向新的软件目录
5、启动新版本软件
[[email protected] mysql5.7.11]# pwd /opt/mysql/mysql5.7.11 [[email protected] mysql5.7.11]# ./bin/mysqld_safe --user=mysql & [1] 3000 [[email protected] mysql5.7.11]# 2016-12-05T09:03:09.133964Z mysqld_safe Logging to ‘/mysqldata/rhel7.err‘. 2016-12-05T09:03:09.161910Z mysqld_safe Starting mysqld daemon with databases from /mysqldata [[email protected] mysql5.7.11]# ps -ef |grep mysql root 3000 1575 0 17:03 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysql mysql 3118 3000 3 17:03 pts/0 00:00:00 /opt/mysql/mysql5.7.11/bin/mysqld --basedir=/opt/mysql/mysql5.7.11 --datadir=/mysqldata --plugin-dir=/opt/mysql/mysql5.7.11/lib/plugin --user=mysql --log-error=/m ysqldata/rhel7.err --pid-file=/mysqldata/rhel7.pidroot 3147 1575 0 17:03 pts/0 00:00:00 grep --color=auto mysql
6、升级数据库
[[email protected] mysql5.7.11]# ./bin/mysql_upgrade -uroot -p 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. sys.sys_config OK test.t_nu OK test.u OK Upgrade process completed successfully. Checking if update is needed.
7、重启MySQL以保证所有升级应用成功
[[email protected] mysql5.7.11]# ./bin/mysqladmin -uroot -p123456 shutdown mysqladmin: [Warning] Using a password on the command line interface can be insecure. [[email protected] mysql5.7.11]# 2016-12-05T09:09:39.211113Z mysqld_safe mysqld from pid file /mysqldata/rhel7.pid ended [1]+ Done ./bin/mysqld_safe --user=mysql [[email protected] mysql5.7.11]# ps -ef |grep mysql root 3162 1575 0 17:09 pts/0 00:00:00 grep --color=auto mysql [[email protected] mysql5.7.11]# ./bin/mysqld_safe --user=mysql & [1] 3163 [[email protected] mysql5.7.11]# 2016-12-05T09:10:02.064621Z mysqld_safe Logging to ‘/mysqldata/rhel7.err‘. 2016-12-05T09:10:02.097210Z mysqld_safe Starting mysqld daemon with databases from /mysqldata [[email protected] mysql5.7.11]# ps -ef |grep mysql root 3163 1575 0 17:10 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysql mysql 3287 3163 2 17:10 pts/0 00:00:00 /opt/mysql/mysql5.7.11/bin/mysqld --basedir=/opt/mysql/mysql5.7.11 --datadir=/mysqldata --plugin-dir=/opt/mysql/mysql5.7.11/lib/plugin --user=mysql --log-error=/m ysqldata/rhel7.err --pid-file=/mysqldata/rhel7.pidroot 3316 1575 0 17:10 pts/0 00:00:00 grep --color=auto mysql [[email protected] mysql5.7.11]# ./bin/mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.11 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show status; +-----------------------------------------------+--------------------------------------------------+ | Variable_name | Value | +-----------------------------------------------+--------------------------------------------------+ | Aborted_clients | 0 | | Aborted_connects | 0 | | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 0 | | Binlog_stmt_cache_disk_use | 0 | | Binlog_stmt_cache_use | 0 | | Bytes_received | 248 | ......
如果不重启可能会报如下错误:
mysql> show status; ERROR 1682 (HY000): Native table ‘performance_schema‘.‘session_status‘ has the wrong structure
官方文档:http://dev.mysql.com/doc/refman/5.7/en/upgrading.html#upgrade-procedure-inplace
本文出自 “DBA Fighting!” 博客,请务必保留此出处http://hbxztc.blog.51cto.com/1587495/1879904
以上是关于MySQL升级从5.6.18到5.7.11的主要内容,如果未能解决你的问题,请参考以下文章
关于阿里云centos 2.6下手机表情输入后无法保存到mysql数据库的问题调研及mysql版本从5.1升级到5.7的全过程纪要