MySQL(4.x)
様々なアプリケーションでデータベースサーバが必要になる場面が出てくることがそ予想されるのでMySQLを導入する。
今回使おうと思っている一部アプリケーションで最新版のVer5で動作確認が取れていないことがわかっているのでVer4を導入する。
# groupadd -g 20020 mysqlMySQLの公式サイトよりソースファイルを入手しインストールする。
# useradd -u 20020 -g 20020 -s /sbin/nologin -d /usr/local/mysql mysql
$ wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.15.tar.gz/from/http://mirror.mysql-partners-jp.biz/
$ tar xvzf mysql-4.1.15.tar.gz
$ cd mysql-4.1.15
$ ./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--with-charset=ujis \
--with-extra-charsets=all
$ make
# make install
権限テーブルを初期化する。
# /usr/local/mysql/bin/mysql_install_db --user=mysqlMySQLのインストールディレクトリのパーミッションを変更する。
Installing all prepared tables
Fill help tables
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/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h boris password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
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
# chown -R mysql:mysql /usr/local/mysql/ソースに含まれているサンプルを基に起動スクリプトを作成する。
# cp support-files/my-medium.cnf /etc/my.cnf
# cp $SOURCE/support-files/mysql.server /etc/rc.d/init.d/mysql起動スクリプトを登録する。
# chmod 755 /etc/rc.d/init.d/mysql # /sbin/chkconfig --add mysql # /sbin/chkconfig --list |grep sql mysql 0:オフ 1:オフ 2:オン 3:オン 4:オン 5:オン 6:オフMySQLを起動する。
# /usr/local/mysql/bin/mysqld_safe --user=mysql &動作確認をする。
[1] 19169
Starting mysqld daemon with databases from /usr/local/mysql/data
# netstat -an Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN # ps -aux |grep mysql root 19169 0.1 0.4 5196 1148 pts/1 S 01:07 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql mysql 19193 1.8 5.7 114200 14636 pts/1 S 01:07 0:00 /usr/local/mysql/libexec/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/local/mysql/data/boris.pid --skip-locking --port=3306 --socket=/tmp/mysql.sockサーバ稼働時のログ。
・・・MySQLサーバに接続できるユーザを制限するためにrootアカウントにパスワードを設定する。 ここでのrootアカウントはシステムのrootアカウントは異なる。
・・・
・・・
# /usr/local/mysql/bin/mysqladmin -u root password '********'
