RedHat ES 3.0にMySQL5.0のrpm版をインストールする
RedHat ES 3.0にMySQL5.0のrpm版をインストールする
0.改訂履歴
1.はじめに
このドキュメントでは,RedHat WS3の最新版Update8に,MySQL5.0.27をインストールする手順を説明する. インストール後,my.cnfを編集して,datadirやold_password,default-character-set等の設定を行う.
なお,使用しているOSは,RedHat Linux ES上で稼働している.
2.環境を確認する
[root@amadeus InstallBin]# cat /etc/redhat-release
Red Hat Enterprise Linux WS release 3 (Taroon Update 8)
[root@amadeus InstallBin]#
|
[root@amadeus admin]# rpm -e --nodeps MySQL-python-0.9.1-6
[root@amadeus admin]# rpm -e --nodeps mysql-bench-3.23.58-16.RHEL3.1
[root@amadeus admin]# rpm -e --nodeps mysql-devel-3.23.58-16.RHEL3.1
[root@amadeus admin]# rpm -e --nodeps qt-MySQL-3.1.2-13.4
[root@amadeus admin]# rpm -e --nodeps mysql-3.23.58-16.RHEL3.1
[root@amadeus admin]# rpm -e --nodeps php-mysql-4.3.2-33.ent
[root@amadeus admin]# rpm -e --nodeps mod_auth_mysql-20030510-2.ent
|
2.インストール
- MySQLの公式サイトから,ダウンロードする.
- ダウンロードしたRPMを確認する.
[root@amadeus InstallBin]# ls -lah *5.0*
-rw-r--r-- 1 root root 6.6M Dec 19 18:10 MySQL-client-standard-5.0.27-0.rhel3.i386.rpm
-rw-r--r-- 1 root root 6.3M Dec 19 18:10 MySQL-devel-standard-5.0.27-0.rhel3.i386.rpm
-rw-r--r-- 1 root root 13M Dec 19 18:10 MySQL-server-standard-5.0.27-0.rhel3.i386.rpm
-rw-r--r-- 1 root root 3.2M Dec 19 18:10 MySQL-shared-compat-5.0.27-0.rhel3.i386.rpm
-rw-r--r-- 1 root root 1.6M Dec 19 18:10 MySQL-shared-standard-5.0.27-0.rhel3.i386.rpm
-rw-r--r-- 1 root root 21M Dec 19 18:11 MySQL-standard-debuginfo-5.0.27-0.rhel3.i386.rpm
[root@amadeus InstallBin]#
|
- 共有ライブラリ(shared*)をインストールする際に,今回は,MySQL3等の下位互換ライブラリを利用するので,compatibleライブラリを選択する.
- よって,shared-standardはインストールしない.
- そして,インストールの最後のプロセスで,serverをインストールする.
[root@amadeus InstallBin]# rpm -ihv MySQL-client-standard-5.0.27-0.rhel3.i386.rpm
warning: MySQL-client-standard-5.0.27-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-client-standard ########################################### [100%]
[root@amadeus InstallBin]# rpm -ihv MySQL-devel-standard-5.0.27-0.rhel3.i386.rpm
warning: MySQL-devel-standard-5.0.27-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-devel-standard ########################################### [100%]
[root@amadeus InstallBin]# rpm -ihv MySQL-shared-compat-5.0.27-0.rhel3.i386.rpm
warning: MySQL-shared-compat-5.0.27-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-shared-compat ########################################### [100%]
[root@amadeus InstallBin]# rpm -ihv MySQL-standard-debuginfo-5.0.27-0.rhel3.i386.rpm
warning: MySQL-standard-debuginfo-5.0.27-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-standard-debuginf########################################### [100%]
[root@amadeus InstallBin]# rpm -ihv MySQL-server-standard-5.0.27-0.rhel3.i386.rpm
warning: MySQL-server-standard-5.0.27-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-server-standard ########################################### [100%]
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 amadeus 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 ]
[root@amadeus InstallBin]#
|
- 問題なければ,MySQLデーモンが起動しているので,確認する.
[root@amadeus InstallBin]# ps -ef | grep mysql
root 4364 1 0 18:14 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/li
b/mysql --pid-file=/var/lib/mysql/amadeus.pid
mysql 4385 4364 0 18:14 pts/0 00:00:00 /usr/sbin/mysqld --basedir=/ --datadir=/var/li
b/mysql --user=mysql --pid-file=/var/lib/mysql/amadeus.pid --skip-external-locking
root 4407 3868 0 18:15 pts/0 00:00:00 grep mysql
[root@amadeus InstallBin]#
|
[root@amadeus InstallBin]# /usr/bin/mysqladmin -u root password 'new-password'
[root@amadeus InstallBin]#
|
- これで,rootユーザのパスワードは,new-passwordに設定された.
3.データディレクトリの変更
- データベースデータファイルが保存されているディレクトリを変更する.
- まず,データベースをシャットダウンする.
[root@amadeus InstallBin]# /usr/bin/mysqladmin -u root -p shutdown
Enter password:
[root@amadeus InstallBin]# ps -ef | grep mysql
root 4419 3868 0 18:16 pts/0 00:00:00 grep mysql
[root@amadeus InstallBin]#
|
- データベースファイルを格納するディレクトリを作成する.
[root@amadeus InstallBin]# mkdir -p /db/DBfile
[root@amadeus InstallBin]#
|
[root@amadeus InstallBin]# ls -lah /var/lib/mysql
total 21M
drwxr-xr-x 4 mysql mysql 4.0K Dec 19 18:16 .
drwxr-xr-x 26 root root 4.0K Dec 19 18:14 ..
-rw-rw---- 1 mysql root 1.3K Dec 19 18:16 amadeus.err
-rw-rw---- 1 mysql mysql 5.0M Dec 19 18:16 ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M Dec 19 18:14 ib_logfile1
-rw-rw---- 1 mysql mysql 10M Dec 19 18:16 ibdata1
drwx--x--x 2 mysql mysql 4.0K Dec 19 18:14 mysql
drwxr-xr-x 2 mysql mysql 4.0K Dec 19 18:14 test
[root@amadeus InstallBin]#
|
[root@amadeus InstallBin]# mv /var/lib/mysql/* /db/DBfile/.
[root@amadeus InstallBin]# ls -lah /var/lib/mysql
total 8.0K
drwxr-xr-x 2 mysql mysql 4.0K Dec 19 18:18 .
drwxr-xr-x 26 root root 4.0K Dec 19 18:14 ..
[root@amadeus InstallBin]#
|
[root@amadeus db]# chown mysql:mysql /dbDBfile
[root@amadeus db]#
|
4.my.cnfを編集する
- my.cnfのテンプレートを利用して,それをテンプレートとする.
- テンプレートファイルを探す.
[root@amadeus InstallBin]# ls -la /usr/share/doc/MySQL-server-standard-5.0.27/
total 96
drwxr-xr-x 2 root root 4096 Dec 19 18:14 .
drwxr-xr-x 601 root root 16384 Dec 19 18:14 ..
-rw-r--r-- 1 root root 19071 Oct 21 09:22 COPYING
-rw-r--r-- 1 root root 1380 Oct 21 09:22 README
-rw-r--r-- 1 root root 4925 Oct 21 13:20 my-huge.cnf
-rw-r--r-- 1 root root 20923 Oct 21 13:20 my-innodb-heavy-4G.cnf
-rw-r--r-- 1 root root 4901 Oct 21 13:20 my-large.cnf
-rw-r--r-- 1 root root 4908 Oct 21 13:20 my-medium.cnf
-rw-r--r-- 1 root root 2478 Oct 21 13:20 my-small.cnf
[root@amadeus InstallBin]#
|
- バージョンに依存しないのであれば,以下のディレクトリを確認すればよい.
[root@amadeus InstallBin]# ls -al /usr/share/mysql/*.cnf
-rwxr-xr-x 1 root root 4925 Oct 21 14:00 /usr/share/mysql/my-huge.cnf
-rwxr-xr-x 1 root root 20923 Oct 21 14:00 /usr/share/mysql/my-innodb-heavy-4G.cnf
-rwxr-xr-x 1 root root 4901 Oct 21 14:00 /usr/share/mysql/my-large.cnf
-rwxr-xr-x 1 root root 4908 Oct 21 14:00 /usr/share/mysql/my-medium.cnf
-rwxr-xr-x 1 root root 2478 Oct 21 14:00 /usr/share/mysql/my-small.cnf
[root@amadeus InstallBin]#
|
[root@amadeus InstallBin]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@amadeus InstallBin]#
|
- 次に,以下のポイントを編集する.
- まずは,クライアントからの接続の際の,文字コードを,SJISに設定する.
変更前 |
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
|
変更後 |
[client]
default-character-set=sjis
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
|
変更前 |
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
|
変更後 |
# The MySQL server
[mysqld]
default-character-set=sjis
datadir=/db/DBfile
log-slow-queries=/db/slow.log
old_passwords
port = 3306
socket = /var/lib/mysql/mysql.sock
|
- この設定では,次のように設定している.
- 文字コードをSJISに
- データ格納ディレクトリを指定
- 1秒以上(デフォルト)の時間のかかったSQL文を格納するファイルを指定
- MySQL4.0以下互換のパスワード認証システムを利用
- 次に,レプリケーション用のバイナリログ設定が行われているので,これを削除する.
変更前 |
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
|
変更後 |
# Replication Master Server (default)
# binary logging is required for replication
#log-bin=mysql-bin
|
- 最後に,mysqldumpとmysqlモニタにも,文字コードの設定を行う.
変更前 |
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
|
変更後 |
[mysqldump]
default-character-set=sjis
quick
max_allowed_packet = 16M
[mysql]
default-character-set=sjis
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
|
5.MySQLサーバを起動する
[root@amadeus InstallBin]# locate mysqld_safe
/usr/share/man/man1/mysqld_safe.1.gz
/usr/bin/mysqld_safe
[root@amadeus InstallBin]# which mysqld_safe
/usr/bin/mysqld_safe
[root@amadeus InstallBin]#
|
[root@amadeus db]# /usr/bin/mysqld_safe &
[1] 4520
[root@amadeus db]# Starting mysqld daemon with databases from /db/DBfile
[root@amadeus db]#
|
- 最後の&を忘れないで付けた上で,実行する.
- ここで起動時にエラーがでる場合は,データフォルダ(このドキュメントだと/db/DBfile以下)にある,"ホスト名.err"という名前のファイルの中身を確認すると,原因が記載されている.
- プロセスを確認する.
[root@amadeus db]# ps -ef | grep mysqld
root 4520 3868 0 18:47 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql 4553 4520 0 18:47 pts/0 00:00:00 /usr/sbin/mysqld --basedir=/ --datadir=/db/DB
file --user=mysql --pid-file=/db/DBfile/amadeus.pid --skip-external-locking --port=3306 --
socket=/var/lib/mysql/mysql.sock
root 4571 3868 0 18:58 pts/0 00:00:00 grep mysqld
[root@amadeus db]#
|