mysqlのインストール

- 参考:
- MySQL: http://www.mysql.com/
- MySQLミラー: http://www.softagency.co.jp/MySQL/
- 日本MySQLユーザー会: http://www.mysql.gr.jp/
ポリシーとしては、とりあえず、/usr/local/mysqlの下にインストールすることにする。
mysqlユーザーとmysqlグループを作る。
/usr/local/mysqlを作ってパーミッションをmysqlに変えておく。以降、mysqlユーザーで作業。
ソースを展開してインストール。
$./configure --prefix=/usr/local/mysql --with-charset=ujis --with-extra-charsets=all --with-mysqld-user=mysql
$make
$make install
環境設定をする。
manやライブラリ、コマンドなどのパスを通す。
PostgreSQLのように.bashrcにこういう風に書いてもいいし、rootになって/etc/ld.so.confと/etc/man.configに書き足してもどちらでも。.bashrcに書いたら、source .bashrcで読み込ませる事を、ld.so.confに書き足したのならldconfigを忘れずに。
PATH="$PATH":/usr/local/mysql/bin
MY=/usr/local/mysql
export MYLIB=$MY/lib/mysql
export MANPATH="$MANPATH":$MY/man
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$MYLIB"
データベースの初期化
データベースの置かれるディレクトリmysql/varを作って、データベースを初期化する。
$ mysql_install_db --user=mysql
パスワードの変更。
データベースを初期化すると
bash-2.04$ mysql_install_db --user=mysql
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
020127 16:14:18 /usr/local/mysql/libexec/mysqld: Shutdown Complete<br>
To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system<br>
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
This is done with:
/usr/local/mysql/bin/mysqladmin -u root -p password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h www.nofuture.tv -p password 'new-password'
See the manual for more instructions.<br>
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/safe_mysqld &<br>
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; run-all-tests<br>
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!<br>
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
のように言われるので、忘れずに変更する。
ちなみにMySQLは、MySQLデータベース内にユーザー管理テーブルがあるので、MySQLを起動していないと変更できません。
$ safe_mysqld --user=mysql &
$ mysqladmin -u root -p password 'fugahoge'
my.cnfと起動スクリプトの登録
ここからは必須ではありませんが、便利に使うための設定をします。
展開したソースの中のsupport-filesディレクトリの下には、各種設定のひな型が入っているのでそれを使います。
my.cnf
メモリの容量に応じて huge, large, medium, smallとあるので適宜選んで、/etc/my.cnfか/usr/local/mysql/var(データベースディレクトリ)/my.cnfにコピーしてください。 my.cnfにパスワードを書く場合、パーミッションを変更するのを忘れないでください。
起動スクリプトの登録(SystemV系)
mysql.serverを /etc/init.d/mysqlでコピーし、実行属性をつけます。 Redhat系なら chkconfig --add mysql、debianなら update-rc.d mysql default 90でinit.d/に登録をします。 あとは、ntsysvとかchkconfigとか、rcconfとかupdate-rc.dでご自由に。