mysql低版本升級到5.7


升級步驟

#安全的停止數據庫的運行
/etc/init.d/mysql.server stop

# 解壓mysql tar包
tar zxf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/
cd /usr/local/

# 刪除原先軟連接,建立新的軟連接
unlink mysql
ln -s mysql-5.7.28-linux-glibc2.12-x86_64/ mysql
        #此時,MySQL的應用程序版本已經升級完成
        #/etc/init.d/mysqld
        #/etc/profile中PATH增加的/usr/local/mysql/bin
        #都不需要做任何的改變,即可將當前系統的mysql版本升級完成
        #注意:此時只是應用程序升級完成,系統表仍然還是5.6的版本
cd /usr/local/mysql
chown root.mysql . -R
/etc/init.d/mysql.server start 

# 執行更新系統表,輸入密碼為原先的密碼
mysql_upgrade -p -s
        #參數 -s 一定要加,表示只更新系統表,-s: upgrade-system-tables
        #如果不加-s,則會把所有庫的表以5.7.9的方式重建,線上千萬別這樣操作
        #因為數據庫二進制文件是兼容的,無需升級
        #什么時候不需要-s ? 當一些老的版本的存儲格式需要新的特性,
        #                 來提升性能時,不加-s
        #即使通過slave進行升級,也推薦使用該方式升級,速度比較快
        
# 查看升級后的版本
mysql -V
# mysql  Ver 14.14 Distrib 5.7.28, for linux-glibc2.12 (x86_64) using  EditLine wrapper

5.1.X5.5.X5.6.X 是可以直接通過該方式升級到5.7.X5.0.X`未知,需要測試

升級完畢后登錄

[root@localhost mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cms                |
| mysql              |
| performance_schema |
| sys                |   # 5.7 新的sys庫
| test               |
+--------------------+
6 rows in set (0.00 sec)

mysql>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM