MySQLのインストール

in
install

データベースをインストールするには専用のユーザを作成しておくと、その後の運用が便利。

#>usergrp mysql
#>usradd mysql -g mysql
#>tar zxvf ./mysql-5.0.18.tar.gz -c /usr/local/src
#>cd /usr/local/src/mysql-5.0.18
#>./configure --with-extra-charsets=all --with-charset=utf8 \
   prefix=/usr/local/mysql
#>make
#>make install

configオプションはお好みで。個人的にはキャラクタセットはutf8をデフォルトにしたほうが悩みが少なくなると考えます。インストールディレクトリは指定したほうが何かと便利です。デフォルトだとincludeとlibがそれぞれ別ディレクトリにインストールされます。インストールしたら用意されている設定ファイルとスタートアップスクリプトのコピー。

#>cp support-files/my-medium.cnf /etc/my.cnf
#>cp /usr/local/src/mysql-5.0.18/support-files/mysql.server ¥
     /etc/init.d/start_mysql
#>cd /etc/rc3.d
#>ln -s ../init.d/start_mysql S99mysql

管理用データベースを作成してパーミッションを変更。

#>cd /usr/local/mysql
#>bin/mysql_install_db --user=mysql
#>chown -R root .
#>chown -R mysql var
#>chgrp -R mysql . 

最後にMySQLのroot(MySQL管理者のことUNIX上のrootとは別物)ユーザにパスワードを設定してインストール完了。MySQLにログインしてデータベースが表示できればOK。

#>/usr/local/mysql/bin/mysqladmin -u root password 'xxxxx' 
#>mysql -u root -p
#mysql>show databases;
+----------------------+
| Database             |
+----------------------+
| information_schema   |
| mysql                |
| test                 |
+----------------------+
3 rows in set (0.12 sec)

Comments