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

时间: 2024-12-30 16:21:57

MySQL升级从5.6.18到5.7.11的相关文章

MySQL5.6.30 升级到MySQL5.7.18

本次升级采用:out of place 逻辑升级方式: 基本步骤:①:停止业务,备份现有数据库(mysqldump方式或者物理备份)②:下载MySQL5.7.18软件包,然后安装到别的目录,③:修改配置my.cnf配置文件,指定basedir为新的软件目录④:启动新版本数据库,然后执行mysql_upgrade -uroot -p 升级数据库:⑤:升级完成,重启数据库⑥:检查升级结果:select version(); 升级MySQL检查:①:现有MySQL数据库是否已经备份②:业务是否已经停止

mysql升级的一些踩坑点

升级的方法一般有两类: 1.利用mysqldump来直接导出sql文件,导入到新库中,这种方法是最省事也最保险 缺点:大库的mysqldump费时费力. 2.直接替换掉 mysql 的安装目录和 my.cnf,利用 mysql_upgrade 来完成系统表的升级,这种方法需要备份原有的文件,但属于物理拷贝,速度较快. 缺点:跨版本升级不推荐这么做,比如mysql5.1升级到mysql5.6,mysql5.5升级到mysql5.7等. 本文采用的是第二种方法升级. 本文两种方法都用到 旧版本 my

Android 4.4 KitKat升级率已经接近18%(2014-07-09 07:29)

腾讯数码讯(编 译:张秀梅)按照惯例, 每个月的第一个星期的星期一谷歌都会发布最新一期Android版本分布图.从去年十月末谷歌发布Android 4.4 KitKat以来,截止到目前为止Android 4.4 KitKat的升级率以及占到了所有Android设备的18%份额,增长势头非常凶猛. 在 最新一个月的Android版本分布图中一个显著的特征就是除了Android 4.4 KitKat在保持快速持续得增长外,其他的Android在占有率上都有不同程度的下降.Android 4.4 Ki

MySQL 升级方法指南大全

MySQL 升级方法指南大全 http://blog.sina.com.cn/s/blog_5a8b8eb80100ld7a.html 通常,从一个发布版本升级到另一个版本时,我们建议按照顺序来升级版本.例如,想要升级 MySQL 3.23 时,先升级到 MySQL 4.0,而不是直接升级到 MySQL 4.1 或 MySQL 5.0. 如果都是比较新的版本的升级可以参考下面的文章, MySQL数据库的版本更新很快,新的特性也随之不断的更新,更主要的是解决了很多影响我们应用的BUG,为了让我们的

Mysql 升级到 5.6 后插入语句时间字段报错:Incorrect datetime value: '' for column 'createtime'

今天部署服务器项目运行,当遇见有时间数据对象的插入和更新操作的时候,就报错,如下: Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'createtime' at row 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2868) at com.mysql.jdbc.My

记Mysql升级的一波三折

环境:mysql-5.1.61 操作系统:Cent-os6.3 目的:升级为mysql 5.6.19 首先,yum是不可行的.因为yum源没更新,我已经使用了163网易的源,但是还是不行.最新版仍然不是5.6.没办法,mysql分区是5.5之后的功能,要使用分区功能,就必须升级.. 去官网下载地址:http://dev.mysql.com/downloads/mysql/ 我是cent os,选择了Red Hat Enterprise Linux版本. 由于系统是i686的,所以选择i686版本

MySQL 升级方法指南大全

原文:MySQL 升级方法指南大全 通常,从一个发布版本升级到另一个版本时,我们建议按照顺序来升级版本.例如,想要升级 MySQL 3.23 时,先升级到 MySQL 4.0,而不是直接升级到 MySQL 4.1 或 MySQL 5.0. 如果都是比较新的版本的升级可以参考下面的文章, MySQL数据库的版本更新很快,新的特性也随之不断的更新,更主要的是解决了很多影响我们应用的BUG,为了让我们的MySQL变得更美好,我们有必要去给它升级,尽管你会说它现在已经跑得很好很稳定完全够用了.下面我们来

mysql升级5.1到5.6

因为Ubuntu的apt库里MySQL最新版本依然是5.1,所以升级MySQL5.5 只有自行下载,并且由于两个版本间改动较大,所以务必先阅读官网的升级事项 upgrading from from MySQL 5.1 to 5.5 ,确保自己的数据库以及配置适用新版. 本文参考了一篇英文指南 A step by step guide to upgrading to MySQL 5.5 但是做了一些顺序和内容上的调整,特别是官网和这篇英文指南都是在升级前mysqldump来备份文件,升级后再将sq

MySQL 升级详细步骤 (包括 Percona)

MySQL 升级步骤 MySQL 5.1.72 升级到 MySQL 5.5.36 鉴于我在升级的时候遇到的麻烦问题,我觉得有必要把一些细节说清楚,免得引起误解了.感觉官方文档上的升级步骤写的比较简单,很容易引起混淆,感觉同我当时参照官方文档学习定制安装 MySQL 一样蛋疼.可能真的是外国淫的思维跟我差距太大了. 数据库情况:本人测试的都是 Linux Generic x86_64 版本的,也是定制安装到制定的数据库目录的. 详细升级步骤 1.MySQL 5.1.72 启动的实例 ins1 假设