mysql5.1.57をmysql5.5.35にした
他プロダクトのリポジトリ落としてsql流し込んだらエラー出た。
ERROR 1115 (42000): Unknown character set: 'utf8mb4'
utf8mb4なんて文字知らないだって((;゚Д゚)
5.5.3以降じゃないと使えないそうなので(手元のmysqlは5.1だった)、mysqlを更新した。
以下は、作業メモ。
本当は更新したかったんだけど、5.1を消して新規インストールしてしまった。
(作業メモ見たら思いっきり削除していた。。)
バックアップしたから良かったけど、商用とかでやってたら死んでいる所だた。別の機会に更新を試す。
mysqlからrpmを落とす。
rpm落とせっていうけど、Select Platformは何を選択すれば良いの?
(そういえば開発環境のOS知らなかった)
OSを確認する
$cat /proc/version Linux version 2.6.18-238.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 16:24:47 EST 2011
CentOSっぽい
rpmはいっぱいあるけど、何を落としてくるの?
入れ替え作業の記録
データをダンプしてバックアップ
$ mysqldump -u root -p --all-database > all.dump
コンフィグのバックアップ
$ cp /etc/my.cnf ~/work/my.cnf.bk
mysqlの停止
$ sudo /etc/init.d/mysql stop
古いの削除 ←!!!?
$ yum remove MySQL-server-community
新しいのインストール
# rpm -i MySQL-server-5.5.35-1.linux2.6.i386.rpm
起動する
# /etc/init.d/mysql start Starting MySQL.The server quit without updating PID file (/[FAILED]mysql/localhost.localdomain.pid).
起動に失敗したのでエラーログ(/usr/local/mysql/var/mysql.err)見る
140110 17:07:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 140110 17:07:41 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. 140110 17:07:41 [Warning] Using unique option prefix thread_cache instead of thread_cache_size is deprecated and will be removed in a future release. Please use the full name instead. 140110 17:07:41 [Warning] ignore-builtin-innodb is deprecated and will be removed in future releases. 140110 17:07:41 [Note] Plugin 'FEDERATED' is disabled. 140110 17:07:41 [ERROR] Can't open shared library '/usr/lib/mysql/plugin/ha_innodb_plugin.so' (errno: 0 /usr/lib/mysql/plugin/ha_innodb_plugin.so: cannot open shared object file: No such file or directory) 140110 17:07:41 [ERROR] Couldn't load plugin named 'innodb' with soname 'ha_innodb_plugin.so'. 140110 17:07:41 [ERROR] /usr/sbin/mysqld: unknown variable 'default-character-set=utf8' 140110 17:07:41 [ERROR] Aborting 140110 17:07:41 [Note] /usr/sbin/mysqld: Shutdown complete 140110 17:07:41 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
innodbがどうとか言ってるのでググった。
5.5からはmy.cnfで設定できない項目があるそうなので修正。
innnodb関係が割りと変わっているみたい。
#ignore-builtin-innodb #plugin-load=innodb=... #default-character-set=utf8 character-set-server=utf8
また失敗した
140110 17:43:15 [ERROR] /usr/sbin/mysqld: unknown variable 'default_table_type=innodb' default-storage-engine = InnoDB
→「default_table_type」ではなく、「default-storage-engine」に修正。
無事に起動した。
その他メモ
character-setにはclientとserverがあるけどclient側のはdefault-character-setのままでOKだった
mysql_upgradeを実行して終了
と思ったらエラー。
# /usr/local/mysql/bin/mysql_upgrade Running 'mysql_fix_privilege_tables'... ERROR 1064 (42000) at line 46: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant'' at line 1 ERROR 1064 (42000) at line 48: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_gene' at line 1 ERROR 1064 (42000) at line 80: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor' at line 1 ERROR 1064 (42000) at line 482: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14) AFTER Proc_priv' at line 2 FATAL ERROR: Upgrade failed
/usr/local/mysql/bin/mysql_upgradeは5.1用のコマンドらしいので
パスが通っているmysql_upgradeを叩けばOKだった。
DBの中身を復元
間違って削除していたので、ダンプしたのを突っ込んだ。
バックアップあってよかった。
mysql -u root < all.dump
テーブル等を突っ込んだので再度mysql_upgradeを実行する
一度実行しているとalready...とか言われるので--forceを付ける
# mysql_upgrade --force
ココを参考にしました↓
【MySQL】5.1から5.5へのアップグレード(rpmで) at softelメモ
Linuxの基礎知識が足りなくて苦戦したけど、起動してよかった。
既存のテストも無事通った。