MySQL-5.5.13 をソースからビルドしたのでメモ。
OS は FreeBSD 7.1-RELEASE-p4 です。
MySQL-5.5.X は configure ではなく cmake を使うようになったようです。
> cmake cmake: Command not found. |
cmake が無いので、まずは cmake をインストールします。
ports からインストールします。
> whereis cmake cmake: /usr/ports/devel/cmake > su - # cd /usr/ports/devel/cmake # make configure # make # make install # pkg_info | grep cmake cmake-2.8.4_1 A cross-platform Makefile generator # which cmake /usr/local/bin/cmake # make clean |
次に MySQL-5.5.13 用にユーザを追加しました。
# pw groupadd mysql55 # pw useradd mysql55 -d /nonexistent -s /sbin/nologin > id mysql55 uid=1001(mysql55) gid=1001(mysql55) groups=1001(mysql55) |
いよいよ MySQL のビルドです。
MySQL も ports でインストールしようかと思ったのですが、イマイチ Makefile で指定した cmake のオプションがどのように影響するのか分からなかったのでソースからビルドする事にしました。
オプションは大体見れば分かると思いますが、 😎
既に MySQL-4.X が稼働しているサーバだったので、PREFIX 、ポート番号、socketのパスを変更しています。
> tar xfz mysql-5.5.13-freebsd7.0-i386.tar.gz > cd mysql-5.5.13 > cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55 -DMYSQL_DATADIR=/usr/local/mysql55/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3307 -DMYSQL_UNIX_ADDR=/tmp/mysql55.sock -DWITH_READLINE=1 > make > su - # make install |
これで MySQL-5.5.13 が /usr/local/mysql55/ にインストールされました。
次は MySQL-5.5.13 の起動です。
データディレクトリを作成します。
# mkdir -p /home/mysql55/db # chown mysql55:mysql55 /home/mysql55/db |
my.cnf コピー
# cp /usr/local/mysql55/support-files/my-medium.cnf /home/mysql55/db/my.cnf # chown mysql55:mysql55 /home/mysql55/db/my.cnf |
my.cnf の変更点。
user = mysql55 を追加。
skip-networking のコメントを外して有効化。コメントアウトって言うの? 🙂
# diff /usr/local/mysql55/support-files/my-medium.cnf /home/mysql55/db/my.cnf 26a27 > user = mysql55 45c46 < #skip-networking --- > skip-networking |
MySQL データ初期化を行います。(mysql_install_db の実行)
# /usr/local/mysql55/scripts/mysql_install_db --basedir=/usr/local/mysql55 --datadir=/home/mysql55/db --user=mysql55 Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/local/mysql55/bin/mysqladmin -u root password 'new-password' /usr/local/mysql55/bin/mysqladmin -u root -h server.example.com password 'new-password' Alternatively you can run: /usr/local/mysql55/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr/local/mysql55 ; /usr/local/mysql55/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/local/mysql55/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/local/mysql55/scripts/mysqlbug script! # ls -l /home/mysql55/db total 12 -rw-r--r-- 1 mysql55 mysql55 4699 Jun 7 08:52 my.cnf drwx------ 2 mysql55 mysql55 2048 Jun 7 09:02 mysql drwx------ 2 mysql55 mysql55 1024 Jun 7 09:02 performance_schema drwx------ 2 mysql55 mysql55 512 Jun 7 09:02 test |
スタートアップスクリプトを作成します。
ソースと一緒に入っているスクリプトをコピーします。
# cp /usr/local/mysql55/support-files/mysql.server /usr/local/etc/rc.d/mysql55-server |
スタートアップスクリプト修正。
元々 linux 用のスクリプトみたいですが、FreeBSD でも大丈夫みたいです。
# vi /usr/local/etc/rc.d/mysql55-server |
以下変更点です。
diff /usr/local/mysql55/support-files/mysql.server /usr/local/etc/rc.d/mysql55-server 27c27,29 < --- > > name="mysql55" > 57,58c59,60 < lockdir='/var/lock/subsys' < lock_file_path="$lockdir/mysql" --- > lockdir='/var/run' > lock_file_path="$lockdir/mysql55" 70c72 < datadir=/usr/local/mysql55/data --- > datadir=/home/mysql55/db 283c285 < $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 & --- > $bindir/mysqld_safe --defaults-file="$datadir/my.cnf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --user=mysql55 $other_args >/dev/null 2>&1 & |
それと、FreeBSD では rc.conf に OS 起動時にスタートさせるスクリプトを指定するようです。
# vi /etc/rc.conf mysql55_enable="YES" を追加しました。 |
mysqld を起動します。
# /usr/local/etc/rc.d/mysql55-server start Starting MySQL.. SUCCESS! # ps awwux | grep mysql で mysql55 が起動した事を確認しました。 |
停止も確認しておきますか。
# /usr/local/etc/rc.d/mysql55-server stop Shutting down MySQL. SUCCESS! # ps awwux | grep mysql で mysql55 が停止した事を確認しました。 |
root のパスワードを設定します。
# /usr/local/mysql55/bin/mysqladmin -u root password 'hogehoge' # /usr/local/mysql55/bin/mysql -uroot Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 4 Server version: 5.5.13-log Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) |
MySQL4.X も問題なく稼働しているようなので、セットアップはここまででひとまず完了です。