MySQL 5.6升級至MySQL 5.7--------版本升級最佳實戰

來源:互聯網
上載者:User

標籤:mysql dba

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  -p123456Warning: 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 2Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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所在目錄

[[email protected] ~]# ll /usr/local/mysql-5.6.36-linux-glibc2.5-x86_64total 72drwxr-xr-x  2 mysql mysql  4096 Jun 24 04:05 bin-rw-r--r--  1 mysql mysql 17987 Mar 18 14:43 COPYINGdrwxr-xr-x  3 mysql mysql  4096 Jun 24 04:05 datadrwxr-xr-x  2 mysql mysql  4096 Jun 24 04:05 docsdrwxr-xr-x  3 mysql mysql  4096 Jun 24 04:05 includedrwxr-xr-x  3 mysql mysql  4096 Jun 24 04:06 libdrwxr-xr-x  4 mysql mysql  4096 Jun 24 04:05 man-rw-r--r--  1 root  root    943 Jun 24 04:08 my.cnfdrwxr-xr-x 10 mysql mysql  4096 Jun 24 04:05 mysql-test-rw-r--r--  1 mysql mysql  2496 Mar 18 14:43 READMEdrwxr-xr-x  2 mysql mysql  4096 Jun 24 04:05 scriptsdrwxr-xr-x 28 mysql mysql  4096 Jun 24 04:05 sharedrwxr-xr-x  4 mysql mysql  4096 Jun 24 04:06 sql-benchdrwxr-xr-x  2 mysql mysql  4096 Jun 24 04:05 support-files


   * MySQL 資料所在目錄

[[email protected] ~]# ll /data/mysql_datatotal 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_logfile1drwx------ 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.piddrwx------ 2 mysql mysql     4096 Jun 24 04:08 performance_schemadrwx------ 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/mysqldatadir=/data/mysql_data

 

3. 升級

   * 正常停止資料庫

[[email protected] mysql]# /etc/init.d/mysqld stopShutting down MySQL.. SUCCESS!


   * 下載 MySQL 5.7 最新版 [ 推薦從MySQL官方下載 ]

[[email protected] ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz


   * 解壓到指定目錄

[[email protected] ~]# tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local/


   * 刪除原有的軟連結

[[email protected] ~]# unlink /usr/local/mysql


   * 建立軟連結指向 MySQL 5.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 startStarting MySQL..... SUCCESS!


   * 利用MySQL 5.7包中的mysql_upgrade 升級MySQL資料中的系統資料表 -p指定密碼

[[email protected] ~]# /usr/local/mysql/bin/mysql_upgrade -s -p123456mysql_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服務查看版本

[[email protected] ~]# /usr/local/mysql/bin/mysql -p123456mysql: [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 5Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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. 總結


以需求驅動技術,技術本身沒有優略之分,只有業務之分。

本文出自 “sea” 部落格,請務必保留此出處http://lisea.blog.51cto.com/5491873/1941616

MySQL 5.6升級至MySQL 5.7--------版本升級最佳實戰

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.