まとめ:CentOS 3.8 に MySQL 4.1 をインストール(前編)

  • 投稿日:
  • by

長々といらない中継まで書いてしまったので、簡潔にインストール手順だけまとめたいと思います。

ちなみに以前に書いたやり方とはちょっとだけ違う部分がありますが、こちらの手順で問題ありません。(後でいろいろいじった結果、簡単なやり方にしただけです。)

まず、MySQL 4.1 の rpm パッケージをダウンロードしてきます。

■ MySQL :: MySQL 4.1 Downloads

上記サイトから以下のパッケージを、/usr/local/bin/ あたりにダウンロード。wget でも何でもいいです。

MySQL-server-standard-4.1.22-0.rhel3.i386.rpm
MySQL-client-standard-4.1.22-0.rhel3.i386.rpm
MySQL-shared-compat-4.1.22-0.rhel3.i386.rpm
MySQL-devel-standard-4.1.22-0.rhel3.i386.rpm

で、以下のコマンドを実行して、mysql 関連のものを削除します。

[root@centos3 root]# yum remove mysql
Gathering header information file(s) from server(s)
Server: CentOS-3 - Addons
Server: CentOS-3 - Base
Server: CentOS-3 - Extras
Server: CentOS-3 - Updates
Finding updated packages
Downloading needed headers
Resolving dependencies
.Dependencies resolved

I will do the following:
[erase: mysql 3.23.58-16.RHEL3.1.i386]
I will erase these to satisfy the dependencies:
[deps: mysql-server 3.23.58-16.RHEL3.1.i386]
[deps: php-mysql 4.3.2-33.ent.i386]
[deps: perl-DBD-MySQL 2.1021-4.EL3.i386]
[deps: mysql-devel 3.23.58-16.RHEL3.1.i386]
[deps: libdbi-dbd-mysql 0.6.5-5.i386]
[deps: MySQL-python 0.9.1-6.i386]
[deps: MyODBC 2.50.39-12.1.i386]
[deps: qt-MySQL 1:3.1.2-13.4.i386]
[deps: mysql-bench 3.23.58-16.RHEL3.1.i386]
[deps: mod_auth_mysql 20030510-2.ent.i386]
Downloading Packages

Running test transaction:
Test transaction complete, Success!
Erasing: MySQL-python 1/11
Erasing: mysql-server 2/11
Erasing: php-mysql 3/11
Erasing: perl-DBD-MySQL 4/11
Erasing: mysql-devel 5/11
Erasing: libdbi-dbd-mysql 6/11
Erasing: MyODBC 7/11
Erasing: mysql 8/11
Erasing: qt-MySQL 9/11
Erasing: mysql-bench 10/11
Erasing: mod_auth_mysql 11/11
Erased:  mysql 3.23.58-16.RHEL3.1.i386 mysql-server 3.23.58-16.RHEL3.1.i386 php-mysql 4.3.2-33.ent.i386 perl-DBD-MySQL 2.1021-4.EL3.i386 mysql-devel 3.23.58-16.RHEL3.1.i386 libdbi-dbd-mysql 0.6.5-5.i386 MySQL-python 0.9.1-6.i386 MyODBC 2.50.39-12.1.i386 qt-MySQL 1:3.1.2-13.4.i386 mysql-bench 3.23.58-16.RHEL3.1.i386 mod_auth_mysql 20030510-2.ent.i386
Transaction(s) Complete

以下のコマンドで rpm パッケージをダウンロードしたディレクトリに移動します。

[root@centos3 root]# cd /usr/local/bin/

んで、rpm コマンドでアップグレードインストールを実行します。

[root@centos3 bin]# rpm -Uvh MySQL-server-standard-4.1.22-0.rhel3.i386.rpm MySQL-client-standard-4.1.22-0.rhel3.i386.rpm MySQL-shared-compat-4.1.22-0.rhel3.i386.rpm MySQL-devel-standard-4.1.22-0.rhel3.i386.rpm 
警告: MySQL-server-standard-4.1.22-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing...                ########################################### [100%]
   1:MySQL-devel-standard   ########################################### [ 25%]
   2:MySQL-server-standard  ########################################### [ 50%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos3 password 'new-password'
See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
Starting MySQL.[  OK  ]
   3:MySQL-client-standard  ########################################### [ 75%]
   4:MySQL-shared-compat    ########################################### [100%]

これで MySQL のインストールは完了です。
インストール直後の状態だと、MySQL が走っているはずなので確認。

[root@centos3 bin]# ps -C mysqld
  PID TTY          TIME CMD
 1629 pts/1    00:00:00 mysqld

で、一度停止させます。

[root@centos3 bin]# service mysql stop
Shutting down MySQL                                       [  OK  ]

再度起動させます。

[root@centos3 bin]# service mysql start
Starting MySQL                                             [  OK  ]

マシンを再起動させても自動起動するように設定します。

[root@centos3 bin]# chkconfig mysql on

確認します。

[root@centos3 bin]# chkconfig --list mysql
mysql           0:オフ  1:オフ  2:オン  3:オン  4:オン  5:オン  6:オフ

これにて MySQL 4.1 は無事インストールできました。

【重要】
ちなみに、yum で MySQL をアンインストールせずに、rpm のパッケージをアップグレードインストールしても失敗します。理由は分かりません。。インストール後、MySQL が自動起動され、そのときは動作するんですが、一度動作を停止させて、再度起動させようとすると失敗します。
MySQL 本体をアップグレードできても、/etc/rc.d/init.d/mysql スクリプトが旧バージョンのままだったりして。。

/////////////// 以下、余談です。お暇ならどうぞ。/////////////////////////

えと、気になった方もいるかも知れませんが、CentOS 3.8 にデフォルトでインストールされる MySQL 3.23 を service で起動する際に以下のように実行させてました。

[root@centos3 root]# service mysqld start

これが、実はアップグレード後は使えなくなります。起動するには、以下のようにコマンドを実行します。

[root@centos3 root]# service mysql start

そうです。実行させるスクリプト名が違ってたんです!
そもそも、service コマンドは /etc/rc.d/init.d/ 内のスクリプトを実行させるためのコマンドです。
3.23 の頃は /etc/rc.d/init.d/ にあるスクリプト名は「mysqld」でした。これがアップグレード後はスクリプトが「mysql」になっているんです!分からずに「mysqld」を実行させると。。。

[root@centos3 root]# service mysqld start
mysqld: unrecognized service

となってしまいます。
今まで通りに「mysqld」にしたい!という人は、 /etc/rc.d/init.d/ 内の「mysql」を「mysqld」にリネームすればOKです。
注意しなければならないのは、MySQL をマシン起動時に自動起動させるように設定している場合、スクリプトをリネームしたら chkconfig コマンドで再度設定を行わなければなりません。

[root@centos3 root]# chkconfig mysqld on

確認してみます。

[root@centos3 root]# chkconfig --list mysqld
mysqld          0:オフ  1:オフ  2:オン  3:オン  4:オン  5:オン  6:オフ

これで、以前と同じように MySQL 4.1 が使えるようになるわけです。