1台のサーバに複数のMySQLをインストールしてみた。


前回はApacheだったが、今回は1台のサーバに複数のMySQL5.0をインストールするメモ。

Source downloads」から「Compressed GNU TAR archive」をダウンロード。



■今回の環境

以下の環境を想定して解説する。

サーバ:CentOS 5
ビット:64bit
MySQLインストールディレクトリ:/home/hoge/mysql
ポート番号:1235



■MySQLインストール

# su - hoge
# wget http://hoge.hoge.hoge/hoge/mysql-5.0.51a.tar.gz
# tar -xvzf mysql-5.0.51a.tar.gz
# cd mysql-5.0.51a
# ./configure --prefix=/home/hoge/mysql \
--with-mysqld-user=hoge \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-tcp-port=1235
...
checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: No curses/termcap library found

上記のようなエラーが発生。

どうやらcursesとかいうものが指定されていないっぽい。これも64bitだからか?



configureのhelpを見たら「with-named-curses-libs」なるものが。

試しにオプションつけて再度実行。

# ./configure --prefix=/home/hoge/mysql \
--with-mysqld-user=hoge \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-tcp-port=1235 \
--with-named-curses-libs=/usr/lib64/libncurses.so.5
# make
# make install

正常にいった。



my-medium.cnfをコピーする。

# cp /home/hoge/mysql-5.0.51a/support-files/my-medium.cnf /home/hoge/mysql/my.cnf

my.cnfを編集する。まずmysql.sockのパスが重複しそうなので変更する。

(修正前) socket = /tmp/mysql.sock
(修正後) socket = /home/hoge/mysql/mysql.sock

ポート番号もconfigure時に設定した値になっているか確認する。



■mysql_install_db

データベースの初期化を行なう。

# cd /home/hoge/mysql-5.0.51a/scripts
# ./mysql_install_db --user=hoge --datadir=/home/hoge/mysql/data



■MySQL起動、動作チェック

デフォルトのmy.cnfを読み込まないようmysqld_safeのオプションで指定する。

# ./mysqld_safe --defaults-file=/home/hoge/mysql/my.cnf \
--pid-file=/home/hoge/mysql/mysqld.pid \
--log-error=/home/hoge/mysql/log/mysqld.log &



ポート番号とmysql.sockを指定してログインする。

念のため、/home/hoge/mysql/bin以下のmysqlを使用した方がよいかもね。

# /home/hoge/mysql/bin/mysql -u root -P1235 --socket=/home/hoge/mysql/mysql.sock

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">

Comments links could be nofollow free.