1. 背景mysql
MySQL 5.7是當前MySQL最新版本,與MySQL 5.6版本相比,有以下特徵linux
* 性能和可擴展性:改進 InnoDB 的可擴展性和臨時表的性能,從而實現更快的網絡和大數據加載等操做。sql
* JSON支持:使用 MySQL 的 JSON 功能,你能夠結合 NoSQL 的靈活和關係數據庫的強大。數據庫
* 改進複製 以提升可用性的性能。包括多源複製,多從線程加強,在線 GTIDs,和加強的半同步複製。 安全
* 性能模式 提供更好的視角。咱們增長了許多新的監控功能,以減小空間和過載,使用新的 SYS 模式顯著提升易用性。bash
* 安全: 咱們貫徹「安全第一」的要求,許多 MySQL 5.7 新功能幫助用戶保證他們數據庫的安全。網絡
* 優化: 重寫了大部分解析器,優化器和成本模型。這提升了可維護性,可擴展性和性能。ide
* 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. 總結
以需求驅動技術,技術自己沒有優略之分,只有業務之分。