バイナリファイルをインストールする方法と、ソースファイルからコンパイルしなおす方法があります。
ここでは、Linuxベースでソースファイルからコンパイルする方法について説明します。
ソースファイルはいろいろなところにあります。例えば、
ftp://ftp.softagency.co.jp/mysql/tcx/Downloads/
取得するファイルは、最新判(2001年4月)mysql-3.23.33.tar.gz です。
これを、ホームディレクトリで展開します。
toro:~$ zcat mysql-3.23.33.tar.gz |tar xvf -
展開が完了したら、カレントディレクトリを移動して、以下のとおり再Makeしてください。
toro:~$ cd mysql-3.23.33
toro:~/mysql-3.23.33$
configureation では漢字を使う場合のために、漢字コードをしておきます。
漢字を使わなければ必要ありません。
toro:~/mysql-3.23.33$
./configure --with-charset=ujis
toro:~/mysql-3.23.33$
make
toro:~/mysql-3.23.33$
su
Password:********
[root@toro mysql-3.23.33]#make
install
MySQLが起動するには、各種設定情報を保存しておくための最低必要なデータベースがひとつ必要
なようです。このデータベースを生成しなければ、MySQLは立ち上がれません。このデータベース
の名前はmysqlで、6つのテーブルを持っています。もうひとつtestという名前の試験用の
データベースも作成されますが、こちらはテーブルが何も作成されていないようです。
以下の手順で、データベースを作成します。
[root@toro mysql-3.23.33]#
cd scripts/
[root@toro scripts]# ./mysql_install_db
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv
table
Preparing columns_priv
table
Installing all prepared
tables
To start mysqld at boot
time you have to copy support-files/mysql.server
to the right place for
your system
PLEASE REMEMBER TO SET
A PASSWORD FOR THE MySQL root USER !
This is done with:
/usr/local/bin/mysqladmin
-u root -p password 'new-password'
/usr/local/bin/mysqladmin
-u root -h toro.zoo.hata.cc -p password 'new-password'
See the manual for more
instructions.
Please report any problems with the /usr/local/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 https://order.mysql.com
[root@toro scripts]#
データベースエンジンの起動および停止のためのスクリプトは、support-filesディレクトに
ありますので、そこに移動します。
まず、起動する前にアドミンツールを使って、データベースエンジンの状態を調べてみます。
以下のコマンドラインでアドミンツールはデータベースに接続して、versionを取得します。
[root@toro support-files]#
mysqladmin version
mysqladmin: connect to
server at 'localhost' failed
error: 'Can't connect
to local MySQL server through socket '/tmp/mysql.sock' (111)'
Check that mysqld is running
and that the socket: '/tmp/mysql.sock' exists!
まだ、データベースを起動していないので、接続に失敗した旨のメッセージが出力されました。
では、データベースを起動してみます。起動には、mysql.serverスクリプトを使用します。
引数に start をとります。
[root@toro support-files]#
sh ./mysql.server start
[root@toro support-files]#
Starting mysqld daemon with databases from /usr/local/var
うまく起動できたかどうか、先ほどとおなじコマンドを使って確認します。
[root@toro support-files]#
mysqladmin version
mysqladmin Ver 8.15
Distrib 3.23.33, for pc-linux-gnu on i686
Copyright (C) 2000 MySQL
AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with
ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to
modify and redistribute it under the GPL license
Server version
3.23.33
Protocol version
10
Connection
Localhost via UNIX socket
UNIX socket
/tmp/mysql.sock
Uptime:
5 sec
Threads: 1 Questions: 1 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 0 Queries per second avg: 0.200
今度はサーバのバージョンや状態が取得できました。
次に停止してみます。
[root@toro support-files]#
sh ./mysql.server stop
Killing mysqld with pid
25120
010409 21:26:21
mysqld ended
停止したことの確認をとります。
[root@toro support-files]#
mysqladmin version
mysqladmin: connect to
server at 'localhost' failed
error: 'Can't connect
to local MySQL server through socket '/tmp/mysql.sock' (111)'
Check that mysqld is running
and that the socket: '/tmp/mysql.sock' exists!
起動前と同じ状態になりました。
では、マシンが起動したときにmysqlサーバも自動に起動するように設定します。
以下の例は、RedHat6.2Jの場合です。プラットフォームによってinitの設定ファイル
が若干異なります。
まず、mysql.serverスクリプトをinit.dにコピーし、実行権を与えておきます。
[root@toro support-files]#cp
./mysql.server /etc/rc.d/init.d
[root@toro support-files]#cd
/etc/rc.d/init.d
[root@toro init.d]# chmod
755 mysql.server
ここでlinuxconfを使って,自動起動設定にしてもよいですし、
もっと細かくrunレベルに応じて設定したい場合は、適切なディレクトリに
このスクリプトのリンクを配置してゆきます。
以下の例は、カーネルがrunレベル3、4、5で起動するときにMySQLサーバも
起動させる場合の例です。
K13mysql.serverおよびS90mysql.serverは、mysql.serverのハードウェアリンクです。
[root@toro rc.d]# find
. -name *mysql* -print
./init.d/mysql.server
./rc0.d/K13mysql.server
./rc1.d/K13mysql.server
./rc2.d/K13mysql.server
./rc3.d/S90mysql.server
./rc4.d/S90mysql.server
./rc5.d/S90mysql.server
./rc6.d/K13mysql.server
ではマシンをリブートして自動に立ち上がってくることを確認してください。
(c) 2001 Hiroaki Hata All rights reserved.