CentOS下將MySQL 5.1升級到MySQL 5.5

來源:互聯網
上載者:User

mysql 5.5已經出來有一段時間,效能有明顯提升,特別是對多核CPU的支援與TPS效能的提升。上周博主介紹了linux下編譯安裝mysql 5.5的步驟,安裝不出意外基本沒有問題。不過可能很多朋友和我一樣一直用的是mysql 5.1,現在想把資料庫升級成5.5了。博主根據實際操作,記錄這次升級操作。

mysql基礎資訊

1、安裝目錄
[root@vm-199~]# /usr/local/mysql
2、設定檔
[root@vm-199~]# /etc/my.cnf
3、資料目錄
[root@vm-199~]# /data/mysql
4、啟動指令碼
[root@vm-199~]# /etc/init.d/mysql

備份資料和安裝、設定檔

[root@vm-199~]# mysqldump -uroot -p –all-databases </root/zhangnq/mysql5.1/mysql_dbk_20140217.sql
[root@vm-199~]# tar czvf mysql_5.1.60_full.tar.gz /usr/local/mysql
[root@vm-199~]# tar czvf mysql_5.1.60_data_full.tar.gz /data/mysql
[root@vm-199~]# cp /etc/my.cnf ./

資料備份好後關閉mysql資料庫,/etc/init.d/mysql stop,刪除/usr/local/mysql檔案。

安裝mysql 5.5

具體可以參考這篇文章《Linux下編譯安裝Mysql-5.5的簡單步驟》(http://www.sijitao.net/1563.html),安裝目錄、資料目錄和5.1的一樣,都是/usr/local/mysql 。

更新設定檔

[root@vm-199 mysql-5.5.35]# cp support-files/my-huge.cnf /etc/my.cnf

在設定檔中添加資料目錄,datadir = /data/mysql 。

啟動mysql 5.5,執行更新程式並重啟mysql

[root@vm-199 mysql-5.5.35]# /etc/init.d/mysql start[root@vm-199 mysql-5.5.35]# /usr/local/mysql/bin/mysql_upgradeLooking for 'mysql' as: /usr/local/mysql/bin/mysqlLooking for 'mysqlcheck' as: /usr/local/mysql/bin/mysqlcheckRunning 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysqld.sock'Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysqld.sock'mydb.t1 OKmydb.t2 OKmysql.columns_priv OKmysql.db OKmysql.event OKmysql.func OKmysql.general_log OKmysql.help_category OKmysql.help_keyword OKmysql.help_relation OKmysql.help_topic OKmysql.host OKmysql.ndb_binlog_index OKmysql.plugin OKmysql.proc OKmysql.procs_priv OKmysql.proxies_priv OKmysql.servers OKmysql.slow_log OKmysql.tables_priv OKmysql.time_zone OKmysql.time_zone_leap_second OKmysql.time_zone_name OKmysql.time_zone_transition OKmysql.time_zone_transition_type OKmysql.user OKRunning 'mysql_fix_privilege_tables'...OK

至此mysql已經更新好了。登陸mysql,檢查資料是否和原來一樣。

這個mysql升級其實不複雜,其實就是重新安裝一遍,然後把資料目錄檔案覆蓋一下。不過資料庫升級,主要還是得注意資料備份,防止資料和意外丟失。


聯繫我們

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