# groupadd mysql # useradd -g mysql -d /dev/null -s /sbin/nologin mysql # # cd /usr/local/src # wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.21.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/ # tar xvzf mysql-5.0.21.tar.gz # cd mysql-5.0.21 # # ./configure --prefix=/usr/local/mysql \ --with-charset=ujis \ --with-extra-charsets=all \ --with-mysqld-user=mysql
オプション説明
--prefix[=DIR] インストール先ディレクトリ(デフォルトは/usr/local) --with-charset 文字コードセット --with-extra-charsets デフォルトの文字コード以外にサポートする文字コード --with-mysqld-user MySQLを起動するユーザ
# make # make install # # cp support-files/my-medium.cnf /etc/my.cnf # # cd /usr/local/mysql/ # bin/mysql_install_db --user=mysql ※新しいMySQL権限テーブルを生成 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 manager01.mss.stnet.co.jp 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 http://shop.mysql.com # # chown -R root . # chown -R mysql var # chgrp -R mysql . # chmod 755 /usr/local/mysql # # vi /etc/ld.so.conf.d/mysql-i386.conf ※新規作成(名前は適当)
/etc/ld.so.conf.d/mysql-i386.conf
以下を追加 /usr/local/mysql/lib/mysql
# ldconfig
# ldconfig -p |grep mysql
libmysqlclient.so.14 (libc6) => /usr/local/mysql/lib/mysql/libmysqlclient.so.14
libmysqlclient.so (libc6) => /usr/local/mysql/lib/mysql/libmysqlclient.so
#
# cd /usr/local/src/mysql-5.0.21
# cp support-files/mysql.server /etc/init.d/mysql
# chmod +x /etc/init.d/mysql
# chkconfig --add mysql
# chkconfig --list |grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#
# /etc/init.d/mysql start
Starting MySQL [ OK ]
#
# mysqladmin ping ※mysqlが動作しているか確認 mysqld is alive # # mysqladmin -u root password <設定するパスワード> ※管理者権限ユーザへのパスワード設定 # # mysql -u root -p mysql
Enter password: 設定した管理者パスワードを入力 Welcome to the MySQL monitor. Commands END with ; OR \g. Your MySQL connection id IS 3 to server version: 5.0.21-LOG Type 'help;' OR '\h' for HELP. Type '\c' to clear the buffer. mysql> SELECT user, host, password FROM mysql.user; +------+----------------------+------------------+ | user | host | password | +------+----------------------+------------------+ | root | localhost | xxxxxxxxxxxxxxx | | root | centos01.example.com | | | | centos01.example.com | | | | localhost | | +------+----------------------+------------------+ 4 rows IN SET (0.01 sec) mysql> DELETE FROM user WHERE password=''; ※匿名ユーザの削除 Query OK, 3 rows affected (0.33 sec) mysql> SELECT user, host, password FROM mysql.user; +------+-----------+------------------+ | user | host | password | +------+-----------+------------------+ | root | localhost | xxxxxxxxxxxxxxxx | +------+-----------+------------------+ 1 row IN SET (0.01 sec) mysql> DELETE FROM mysql.db; Query OK, 2 rows affected (0.01 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye