Solaris10にプリインストールされているMySQLを設定する
Solaris10に最初から入っているMySQLを使うための設定を行った.
■設定のためのリードミードキュメントを読む
/etc/sfw/mysql/README.solaris.mysql
To use mysql a number of post-install procedures need to be made by root.
The following steps are derived from the mysql manual (manual.ps, manual.txt or
manual_toc.html) found in the /usr/sfw/src/mysql/Docs directory.
Initialise the database tables.
# /usr/sfw/bin/mysql_install_db
Create mysql user and group and change data directory group.
# groupadd mysql
# useradd -g mysql mysql
# chgrp -R mysql /var/mysql
# chmod -R 770
# installf SUNWmysqlr /var/mysql d 770 root mysql
MySQL reads configuration files from different places in the following order.
Filename Purpose
--------- ---------
/etc/my.cnf Global options
DATADIR/my.cnf Server-specific options
defaults-extra-file The file specified with
--defaults-extra-file=path
~/.my.cnf User-specific options
Optionally copy a mysql daemon configuration file to configuration directory.
Note there are other configuration profiles available.
For default solaris installation DATADIR is /var/mysql.
# cp /usr/sfw/share/mysql/my-medium.cnf /var/mysql/my.cnf
Start mysql daemon by hand
# /usr/sfw/sbin/mysqld_safe --user=mysql &
Optionally perform the following steps for automatic start and stop of
mysql daemon at boot and shutdown.
Link boot time start up script from rc3.d and rc[012S].d
# ln /etc/sfw/mysql/mysql.server /etc/rc3.d/S99mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc0.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc1.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc2.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rcS.d/K00mysql
■設定リードミードキュメントの通り実行する
# /usr/sfw/bin/mysql_install_db
# groupadd mysql
# useradd -g mysql mysql
# chgrp -R mysql /var/mysql
# chmod -R 770 /var/mysql (マニュアルはここが抜けていた)
# installf SUNWmysqlr /var/mysql d 770 root mysql
# cp /usr/sfw/share/mysql/my-medium.cnf /etc/my.cnf (varではなくetcだと思う)
リードミーでは、/var/mysql/my.cnfと書いてあるけど、起動ファイルの/etc/sfw/mysql/mysql.server を見てみると、そのような記述はない。たぶん、リードミーの書き間違いかな...。
■MySQLを起動する
とりあえず起動して、動作確認する。
シェルスクリプト mysqld_safe に引数を付けて実行する。
# /usr/sfw/sbin/mysqld_safe --user=mysql &
■MySQLクライアントから接続する
とりあえず、接続できるかを確認する。
# /usr/sfw/bin/mysql -u root
データベースが存在していることを確認する。
mysql> show databases;
mysql> exit;
■MySQLが自動起動するようにしておく
サーバ再起動時にMySQLが自動で起動するようにしておく。
/etc/init.d/mysql を用意して、rc*.d ごとにシンボリックリンクを張った。
起動スクリプトを変更したくなったら、/etc/init.d/mysqlだけを変更すればOK。
# cd /etc/init.d/
# ln -s /etc/sfw/mysql/mysql.server mysql
# cd /etc/rc3.d/
# ln -s /etc/init.d/mysql S99mysql
# cd /etc/rc0.d/
# ln -s /etc/init.d/mysql K00mysql
# cd /etc/rc1.d/
# ln -s /etc/init.d/mysql K00mysql
# cd /etc/rc2.d/
# ln -s /etc/init.d/mysql K00mysql
# cd /etc/rcS.d/
# ln -s /etc/init.d/mysql K00mysql
■データの引っ越しを行う
今まで使っていた、MySQLのデータを予めtarで固めておいて、それをftpで持ってきて解凍すればそのまま使える。
解凍先は、/var/mysql/でも良いし、自分の好きな場所でも良い.自分の場合は容量がたくさんとれる/export/home/mysql/mysql4/data/ として保存した。
$ cd /export/home/mysql/mysql4
$ tar xvf data.tar
/export/home/mysql/mysql4/data/ をデータディレクトリとして認識するように、起動スクリプト/etc/init.d/mysqlを変更する。
/etc/init.d/mysql の次の行を変更する。
datadir=/var/mysql
↓
datadir=/export/home/mysql/mysql4/data
mysqlを再起動して有効にする。
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
引っ越し前のサーバがSPARCで、新しい引っ越し先がX64だけど問題なく動いた。バイナリ互換らしい。
同じバージョンのMySQL 4.0.24同士だったから楽だった。
- 14502 reads