今天做了MySQL升級,從 5.1.26-rc 升級 到 5.5.15,都是從官網下載的源碼包進行編譯的,其中MySQL 5.5.15是由我的同事提供的。
由於現有資料庫採用innodb的引擎,故採用mysqldump匯出備份,然後再匯入備份的方式進行升級。
升級大致步驟準備:
1、對現有資料庫做備份
2、對現有的MySQL程式重新命名(防止升級失敗還能恢複)
3、對現有許可權庫做單獨備份
4、替換現有MySQL程式
5、啟動MySQL 5.5.15,匯入備份
註:特別注意mysql日誌提示
在升級後啟動MySQL 5.5.15的過程中遇到很多提示錯誤,根據錯誤提示加以修改,很快解決問題。
a、我所安裝升級的MySQL 5.5.15,編譯目錄選擇的是/usr/local/mysql,但是我們線上的資料庫程式所在目錄為/usr/local/mysql5,我按照線上的進行升級,也將程式按照線上服務部署,故在啟動的過程中提示如下錯誤:
120717 11:19:41 mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
解決方案:將程式目錄更改為/usr/local/mysql
b、設定檔中有[mysqld]選項段有如下選項--log-slow-queries,這個選項屬於老版本的選項,根據mysql記錄檔GY_ZGC_97.err錯誤提示加以修改:
120717 11:21:32 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data
120717 11:21:32 [Warning] The syntax '--log-slow-queries' is deprecated and will be removed in a future release. Please use '--slow-query-log'/'--slow-query-log-file' instead.
120717 11:21:32 InnoDB: The InnoDB memory heap is disabled
120717 11:21:32 InnoDB: Mutexes and rw_locks use InnoDB's own implementation
120717 11:21:32 InnoDB: Compressed tables use zlib 1.2.3
120717 11:21:33 InnoDB: Initializing buffer pool, size = 1000.0M
120717 11:21:33 InnoDB: Completed initialization of buffer pool
解決方案:將設定檔中的log-slow-queries替換為slow-query-log
c、mysql啟動有個選項--datadir,該選項指定的目錄沒有許可權問題:
120717 11:21:33 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
120717 11:21:33 mysqld_safe mysqld from pid file /home/mysql/data/GY_ZGC_97.pid ended
解決方案:將mysql資料目錄屬主更改為mysql使用者:chown -R mysql.mysql data
d、mysql設定檔有如下選項:default-character-set=utf8
120717 11:22:46 InnoDB: 1.1.8 started; log sequence number 0
120717 11:22:46 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'default-character-set=utf8'
120717 11:22:46 [ERROR] Aborting
120717 11:22:46 InnoDB: Starting shutdown...
120717 11:22:47 InnoDB: Shutdown completed; log sequence number 1595675
120717 11:22:47 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
120717 11:22:47 mysqld_safe mysqld from pid file /home/mysql/data/GY_ZGC_97.pid ended
解決方案:注釋掉該選項