MySQL 5.6升级至MySQL 5.7
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL 5.6升级至MySQL 5.7相关的知识,希望对你有一定的参考价值。
1. 背景
mysql 5.7是当前MySQL最新版本,与MySQL 5.6版本相比,有如下特征
* 性能和可扩展性:改进 InnoDB 的可扩展性和临时表的性能,从而实现更快的网络和大数据加载等操作。
*JSON支持:使用 MySQL 的 JSON 功能,你可以结合 NoSQL 的灵活和关系数据库的强大。
* 改进复制 以提高可用性的性能。包括多源复制,多从线程增强,在线 GTIDs,和增强的半同步复制。
* 性能模式 提供更好的视角。我们增加了许多新的监控功能,以减少空间和过载,使用新的 SYS 模式显著提高易用性。
* 安全: 我们贯彻“安全第一”的要求,许多 MySQL 5.7 新功能帮助用户保证他们数据库的安全。
* 优化: 重写了大部分解析器,优化器和成本模型。这提高了可维护性,可扩展性和性能。
*GIS: MySQL 5.7 全新的功能,包括 InnoDB 空间索引,使用 Boost.Geometry,同时提高完整性和标准符合性。
2. 当前运行的MySQL 5.6环境
*MySQL当前版本
[[email protected] ~]#/usr/local/mysql/bin/mysql -p123456
Warning: Using a password on the commandline interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.36 MySQL CommunityServer (GPL)
Copyright (c) 2000, 2017, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.36 |
+-----------+
1 row in set (0.05 sec)
mysql>
*MySQL所在目录
[[email protected] ~]# ll /usr/local/mysql-5.6.36-linux-glibc2.5-x86_64
total 72
drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05bin
-rw-r--r-- 1 mysql mysql 17987 Mar 18 14:43 COPYING
drwxr-xr-x 3 mysql mysql 4096 Jun 24 04:05data
drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05docs
drwxr-xr-x 3 mysql mysql 4096 Jun 24 04:05include
drwxr-xr-x 3 mysql mysql 4096 Jun 24 04:06lib
drwxr-xr-x 4 mysql mysql 4096 Jun 24 04:05man
-rw-r--r-- 1 root root 943 Jun 24 04:08 my.cnf
drwxr-xr-x 10 mysql mysql 4096 Jun 24 04:05 mysql-test
-rw-r--r-- 1 mysql mysql 2496 Mar 18 14:43README
drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05scripts
drwxr-xr-x 28 mysql mysql 4096 Jun 24 04:05 share
drwxr-xr-x 4 mysql mysql 4096 Jun 24 04:06sql-bench
drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05support-files
*MySQL 数据所在目录
[[email protected] ~]# ll /data/mysql_data
total 110616
-rw-rw---- 1 mysql mysql 56 Jun 24 04:10 auto.cnf
-rw-rw---- 1 mysql mysql 12582912 Jun 2404:10 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Jun 2404:10 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Jun 2404:08 ib_logfile1
drwx------ 2 mysql mysql 4096 Jun 24 04:08 mysql
-rw-rw---- 1 mysql mysql 1771 Jun 24 04:10 MySQL.err
-rw-rw---- 1 mysql mysql 6 Jun 24 04:10 MySQL.pid
drwx------ 2 mysql mysql 4096 Jun 24 04:08 performance_schema
drwx------ 2 mysql mysql 4096 Jun 24 04:08 test
*MySQL 启动脚本basedir与datadir设置
[[email protected] ~]# grep -E‘^basedir=|^datadir=‘ /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql_data
3. 升级
* 正常停止数据库
[[email protected] mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
* 下载 MySQL 5.7 最新版 [ 推荐从MySQL官方下载 ]
[[email protected] ~]# wgethttps://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
* 解压到指定目录
[[email protected] ~]# tar zxvfmysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
* 删除原有的软链接
[[email protected] ~]# unlink /usr/local/mysql
* 新建软链接指向 MySQL5.7目录
[[email protected] ~]# ln -s /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/usr/local/mysql
* 通过脚本启动MySQL
[[email protected] ~]# /etc/init.d/mysqld start
Starting MySQL..... SUCCESS!
* 利用MySQL 5.7包中的mysql_upgrade升级MySQL数据中的系统表 -p指定密码
[[email protected] ~]#/usr/local/mysql/bin/mysql_upgrade -s -p123456
mysql_upgrade: [Warning] Using a passwordon the command line interface can be insecure.
The --upgrade-system-tables option wasused, databases won‘t be touched.
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Upgrading the sys schema.
Upgrade process completed successfully.
Checking if update is needed.
* 连接MySQL服务查看版本
[[email protected] ~]# /usr/local/mysql/bin/mysql-p123456
mysql: [Warning] Using a password on thecommand line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.18 MySQL CommunityServer (GPL)
Copyright (c) 2000, 2017, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.18 |
+-----------+
1 row in set (0.00 sec)
以上是关于MySQL 5.6升级至MySQL 5.7的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 从 5.6 升级到 5.7 的 Grails 更改