mysql: mysql5.1.41をソースからインストール

mysqlをソースからインストールする。
pluginは全部有効にする。

cd /usr/local/src
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
tar zxfv mysql-5.1.41.tar.gz
cd mysql-5.1.41
./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-mysqld-user=mysql \
--with-plugins=max \
--enable-local-infile
make
make install
以上でインストールは完了。
※この段階でエラーが出る場合は後述のエラーがでるときを参照

次に初期設定をおこなう。
ソースの雛形からmy.cnf を作成する。
cp support-files/my-medium.cnf /etc/my.cnf
作成したmy.cnf に文字コードの設定を追加する。
mysqld、mysqldump、mysql セクションにそれぞれ以下の設定を追加する。
[mysqld]
default-character-set=utf8
skip-character-set-client-handshake
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8
[mysqldump]
default-character-set = utf8
[mysql]
default-character-set = utf8
mysqlを起動する前に、mysql 用のユーザを追加する。
groupadd mysql
useradd -g mysql mysql
mysql のインストールフォルダのオーナーをmysql ユーザに変更する。
chown -R mysql:mysql /usr/local/mysql

次に、データベースを初期化を行う。
cd /usr/local/mysql
bin/mysql_install_db --user=mysql


MySQL サーバーを起動する。
./bin/mysqld_safe --user=mysql &

※mysql起動後はrootユーザログインできるようになる。
初期状態ではrootにパスワードが設定されていないので、必ずrootユーザのパスワードを設定すること。


mysqlのconfigure,makeでエラーがでるとき

もし./configureでこんなエラーがでたら
checking for termcap functions library... configure: error: No curses/termcap library found

ncurses-develというものをインストールすればconfigureできるようになる。
yum install ncurses-devel

もしmakeでこんなエラーがでたら
../depcomp: line 571: exec: g++: not found
make[1]: *** [my_new.o] エラー 127
make[1]: ディレクトリ `/usr/local/src/mysql-5.1.41/mysys' から出ます™
make:

gcc-c++をインストールする。
yum install gcc-c++

このままmakeすると、以下のようなエラーになるので、
licit-templates -fno-exceptions -fno-rtti -c -o my_new.o my_new.cc
../include/my_global.h:1099: error: redeclaration of C++ built-in type '˜bool'

make cleanしてconfigureからやりなおすこと。
make clean
./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-mysqld-user=mysql \
--with-plugins=max \
--enable-local-infile

make

make install

No comments yet.

Write a comment: