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当前版本
[root@MySQL ~]# /usr/local/mysql/bin/mysql -p123456 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.6.36 MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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> select version(); +-----------+ | version() | +-----------+ | 5.6.36 | +-----------+ 1 row in set (0.05 sec) mysql>
* MySQL所在目录
[root@MySQL ~]# ll /usr/local/mysql-5.6.36-linux-glibc2.5-x86_64 total 72 drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05 bin -rw-r--r-- 1 mysql mysql 17987 Mar 18 14:43 COPYING drwxr-xr-x 3 mysql mysql 4096 Jun 24 04:05 data drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05 docs drwxr-xr-x 3 mysql mysql 4096 Jun 24 04:05 include drwxr-xr-x 3 mysql mysql 4096 Jun 24 04:06 lib drwxr-xr-x 4 mysql mysql 4096 Jun 24 04:05 man -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:43 README drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05 scripts drwxr-xr-x 28 mysql mysql 4096 Jun 24 04:05 share drwxr-xr-x 4 mysql mysql 4096 Jun 24 04:06 sql-bench drwxr-xr-x 2 mysql mysql 4096 Jun 24 04:05 support-files
* MySQL 数据所在目录
[root@MySQL ~]# 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 24 04:10 ibdata1 -rw-rw---- 1 mysql mysql 50331648 Jun 24 04:10 ib_logfile0 -rw-rw---- 1 mysql mysql 50331648 Jun 24 04: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设置
[root@MySQL ~]# grep -E '^basedir=|^datadir=' /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/data/mysql_data
3. 升级
* 正常停止数据库
[root@MySQL mysql]# /etc/init.d/mysqld stop Shutting down MySQL.. SUCCESS!
* 下载 MySQL 5.7 最新版 [ 推荐从MySQL官方下载 ]
[root@MySQL ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
* 解压到指定目录
[root@MySQL ~]# tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
* 删除原有的软链接
[root@MySQL ~]# unlink /usr/local/mysql
* 新建软链接指向 MySQL 5.7目录
[root@MySQL ~]# ln -s /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql
* 通过脚本启动MySQL
[root@MySQL ~]# /etc/init.d/mysqld start Starting MySQL..... SUCCESS!
* 利用MySQL 5.7包中的mysql_upgrade 升级MySQL数据中的系统表 -p指定密码
[root@MySQL ~]# /usr/local/mysql/bin/mysql_upgrade -s -p123456 mysql_upgrade: [Warning] Using a password on the command line interface can be insecure. The --upgrade-system-tables option was used, 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服务查看版本
[root@MySQL ~]# /usr/local/mysql/bin/mysql -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 5 Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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> select version(); +-----------+ | version() | +-----------+ | 5.7.18 | +-----------+ 1 row in set (0.00 sec)
4. 总结
以需求驱动技术,技术本身没有优略之分,只有业务之分。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。