MySQL 5.5升級5.6 單例項簡易實戰
環境:RHEL 6
mysql舊版本:mysql-5.5.28
mysql新版本:mysql-5.6.26
安裝方式:原始碼編譯
不習慣用rpm包來安裝mysql,所以此處仍然使用用原始碼安裝編譯mysql。
若為rpm包安裝,操作過程大體一致,當然路徑和安裝方法有出入。
因為是實驗環境,首先安裝mysql5.5。
basedir : /home/sano1y/mysql5.5
datadir : /home/sano1y/mysql5.5/data
socket : /tmp/mysql.sock
配置檔案路徑 : /home/sano1y/.my.cnf
此處作業系統使用者名稱為sano1y,下同。
安裝過程略。
安裝完後配一下使用者環境變數
將預設配置檔案放到~/.my.cnf
② 備份資料庫
備份資料檔案,略。
同時備份引數檔案。
③ 安裝新版本
同樣通過cmake make make install來編譯安裝 mysql5.6,並初始化
並修改使用者環境變數。
將預設5.6的配置檔案修改掉(禁用)
將對應引數修改為新的。
④ 啟動新版本服務
此時mysql伺服器會找到 ~/.my.cnf這個配置檔案,並啟用。
⑤ 檢查升級的表
此時做mysql_upgrade進行檢查
然後是mysqlcheck
進入mysql client檢查:
此時密碼仍然是mysql5.5的,因為啟動時,是在/home/sano1y/mysql5.5/data/中的mysql.user中校驗。
順便可以刪一下mysql5.5目錄裡的其他目錄:
總結升級過程:
① 停止舊版本服務 → ② 備份資料庫 → ③ 安裝新版本 → ④ 啟動新版本服務 → ⑤ 檢查升級的表
作者公眾號(持續更新)

mysql舊版本:mysql-5.5.28
mysql新版本:mysql-5.6.26
安裝方式:原始碼編譯
不習慣用rpm包來安裝mysql,所以此處仍然使用用原始碼安裝編譯mysql。
若為rpm包安裝,操作過程大體一致,當然路徑和安裝方法有出入。
因為是實驗環境,首先安裝mysql5.5。
basedir : /home/sano1y/mysql5.5
datadir : /home/sano1y/mysql5.5/data
socket : /tmp/mysql.sock
配置檔案路徑 : /home/sano1y/.my.cnf
此處作業系統使用者名稱為sano1y,下同。
安裝過程略。
安裝完後配一下使用者環境變數
- vi ~/.bash_profile
- 新增 export PATH=$PATH:/home/sano1y/mysql5.5/bin
- source ~/.bash_profile
將預設配置檔案放到~/.my.cnf
- cp ~/mysql5.5/support-files/my-medium.cnf ~/.my.cnf
先啟動服務,修改一下初始密碼並確認版本:
因為5.5、5.6版本的密碼均為空,所以先指定一個密碼,後面將會用到。
① 停止舊版本服務
-
- [sano1y@localhost ~]$ mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 5
- Server version: 5.5.28-log Source distribution
- Copyright (c) 2000, 2012, 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>
- mysql> set password=password('root');
- Query OK, 0 rows affected (0.00 sec)
- mysql>
- mysql> flush privileges;
- Query OK, 0 rows affected (0.00 sec)
① 停止舊版本服務
- [sano1y@localhost bin]$ mysqladmin -uroot -p shutdown
- Enter password:
- 151125 00:13:35 mysqld_safe mysqld from pid file /home/sano1y/mysql5.5/data/localhost.localdomain.pid ended
- [1]+ Done ./mysqld_safe
- [sano1y@localhost mysql5.6]$ ps -ef | grep mysql
- sano1y 20590 19687 0 02:00 pts/2 00:00:00 grep mysql
-
② 備份資料庫
備份資料檔案,略。
同時備份引數檔案。
- cp ~/.my.cnf ~/.my.cnf.bk
③ 安裝新版本
同樣通過cmake make make install來編譯安裝 mysql5.6,並初始化
並修改使用者環境變數。
- vi ~/.bash_profile
- export PATH=$PATH:/home/sano1y/mysql5.6/bin
- source ~/.bash_profile
將預設5.6的配置檔案修改掉(禁用)
- mv ~/mysql5.6/my.cnf ~/mysql5.6/my.cnf.default
將對應引數修改為新的。
- vi ~/.my.cnf
- [mysqld]
- basedir=/home/sano1y/mysql5.6
- datadir=/home/sano1y/mysql5.5/data
- pid-file=/home/sano1y/mysql5.5/sAno1y.pid
④ 啟動新版本服務
- mysqld_safe & 啟動服務
⑤ 檢查升級的表
此時做mysql_upgrade進行檢查
- mysql_upgrade -uroot -p --force
- mysqlcheck -uroot -p
進入mysql client檢查:
此時密碼仍然是mysql5.5的,因為啟動時,是在/home/sano1y/mysql5.5/data/中的mysql.user中校驗。
- [sano1y@localhost bin]$ mysql -uroot -p
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 26
- Server version: 5.6.26-log Source distribution
- Copyright (c) 2000, 2012, 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 @@datadir;
- +-----------------------------+
- | @@datadir |
- +-----------------------------+
- | /home/sano1y/mysql5.5/data/ |
- +-----------------------------+
- 1 row in set (0.00 sec)
順便可以刪一下mysql5.5目錄裡的其他目錄:
- [sano1y@localhost ~]$ cd mysql5.5
- [sano1y@localhost mysql5.5]$ ls
- bin data include lib mysql-test scripts sql-bench sAno1y.pid
- COPYING docs INSTALL-BINARY man README share support-files
- [sano1y@localhost mysql5.5]$ rm -rf bin/ include/ lib/ mysql-test/ scripts/ sql-bench/ COPYING docs/ INSTALL-BINARY man/ README share/ support-files/
- [sano1y@localhost mysql5.5]$
- [sano1y@localhost mysql5.5]$ ls
-
data sAno1y.pid
總結升級過程:
① 停止舊版本服務 → ② 備份資料庫 → ③ 安裝新版本 → ④ 啟動新版本服務 → ⑤ 檢查升級的表
作者公眾號(持續更新)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29773961/viewspace-1846662/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 超級簡單入門vuex 小例項Vue
- 網易雲 MySQL例項遷移的技術實現MySql
- 單例項mysql.yaml kubernetes單例MySqlYAML
- MySQL:5.6 升級 5.7MySql
- opengl簡單入門例項
- Spark 簡單例項(基本操作)Spark單例
- 3.3 - Laravel - 5.6 - Route - 載入單個Route例項的主要流程Laravel
- 輕量級網站建設jsonp跨域簡單例項網站JSON跨域單例
- html實現簡單ListViews效果的例項程式碼HTMLView
- EventBus詳解及簡單例項單例
- canal同步mysql,監聽單例項,多例項配置MySql單例
- Python專案實戰例項Python
- FastAPI實戰:簡易MockServeASTAPIMock
- MySQL實戰 | 06/07 簡單說說MySQL中的鎖MySql
- Java的Socket通訊簡單例項Java單例
- ElasticSearch客戶端簡單操作例項Elasticsearch客戶端
- 簡單的單例模式其實也不簡單單例模式
- 淡入淡出效果簡單程式碼例項
- XML節點自動生成簡單例項XML單例
- C#out引數的簡單例項C#單例
- C++學習隨筆——簡單的單例設計模式例項C++單例設計模式
- Python實現簡單網頁圖片抓取完整程式碼例項Python網頁
- Redis實戰篇(一)搭建Redis例項Redis
- phpqrcode生成動態二維碼簡單例項PHP單例
- Python簡單函式迴圈綜合例項Python函式
- centos7 mysql5.6升級5.7CentOSMySql
- python 單一程式例項 實現Python
- Flutter mvvm簡單實戰FlutterMVVM
- mysql 5.6 升級 到 5.7 的二進位制升級方法 另一個簡便思路.MySql
- Android 簡單瀏覽器例項-webview控制元件Android瀏覽器WebView控制元件
- [邊學邊練]用簡單例項學習React單例React
- MySQL:5.6 大事務show engine innodb status故障一例MySql
- MYSQL: 表表示式(CTE)實現遞迴例項MySql遞迴
- Spring Cloud超簡單十分鐘入門例項SpringCloud
- keras轉tensorflow lite【方法二】直接轉:簡單模型例項Keras模型
- PHP+jQuery開發簡單的翻牌抽獎例項PHPjQuery
- python3將變數輸入的簡單例項Python變數單例
- Gin與Mysql實現簡單Restful風格API實戰示例詳解PRHCMySqlRESTAPI
- 簡易版的Spring框架之IOC簡單實現Spring框架