MySQL 5.6升級至MySQL 5.7

來源:互聯網
上載者:User

標籤:升級   mysql   

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.