| トップ | Solaris | FreeBSD | Gentoo | CentOS | Fedora | Windows | Tips | 自宅サーバの動作確認 | サイト内検索(Namazu) | サイト内検索(HE) |
「MySQL」をソースからインストールしましたので、ここでのインストールはソースから行っています。
「MySQL」用ユーザの作成
「MySQL」用のユーザを作成します。
Solaris# groupadd -g 3306 mysql <= グループの作成 Solaris# useradd -u 3306 -g mysql -d /usr/local/mysql -s /bin/false mysql <= ユーザの作成 Solaris# chown -R mysql:mysql /usr/local/mysql <= ホームディレクトリのオーナ・グループの変更 |
「MySQL」用のインストール
「MySQL」のソースファイルをダウンロードし、インストールします。
Solaris# mkdir /usr/local/src/mysql <= 作業用ディレクトリの作成 Solaris# chmod 777 /usr/local/src/mysql <= 作業用ディレクトリのパーミッション変更 Solaris# exit <= 一般ユーザになる Solaris% cd /usr/local/src/mysql <= 作業用ディレクトリへ移動 Solaris% wget http://download.softagency.net/MySQL/Downloads/MySQL-5.0/mysql-5.0.51.tar.gz <= 「MySQL」のソースをダウンロード Solaris% gunzip -c mysql-5.0.51.tar.gz | tar xf - <= ダウンロードしたファイルの展開 Solaris% cd mysql-5.0.51 <= 展開したディレクトリに移動 Solaris% ./configure --prefix=/usr/local/mysql \ --libexecdir=/usr/local/mysql/bin \ --enable-thread-safe-client \ --enable-local-infile \ --enable-shared=yes \ --with-charset=ujis \ --with-extra-charsets=all \ --with-mysqld-user=mysql \ --with-big-tables \ --with-openssl=/usr/sfw \ --with-openssl-includes=/usr/sfw/include \ --with-openssl-libs=/usr/sfw/lib |& tee configure.log Solaris% gmake |& tee make.log <= コンパイル Solaris% su <= スーパーユーザになる Password: <= パスワードの入力 Solaris# gmake install |& tee make-install.log <= インストール Solaris# cp support-files/my-medium.cnf /etc/my.cnf <= 設定ファイルのコピー |
「MySQL」の設定
自分は念の為、以下の2行を設定ファイルに追加しました。
Solaris# vi /etc/squid.cnf <= 設定ファイルの編集 [mysqld] basedir=/usr/local/mysql <= 追加(インストールディレクトリのパス) datadir=/usr/local/mysql/data <= 追加(MySQLのデータディレクトリのパス) |
「MySQL」の初期化
mysql_install_dbコマンドでデータベースを作成します。
Solaris# /usr/local/mysql/bin/mysql_install_db --user=mysql |
「MySQL」の起動
ソースの中にある起動スクリプトを利用します。
Solaris# cp /usr/local/src/mysql/mysql-5.0.51/support-files/mysql.server /etc/init.d/mysql.server <= サンプル設定ファイルのコピー Solaris# chmod 744 /etc/init.d/mysql.server <= 起動スクリプトファイルに実行権限付加 Solaris# ln /etc/init.d/mysql.server /etc/rc2.d/S99mysql.server <= ランレベル2で起動する Solaris# ln /etc/init.d/mysql.server /etc/rc3.d/S99mysql.server <= ランレベル3で起動する Solaris# ln /etc/init.d/mysql.server /etc/rc0.d/K99mysql.server <= ランレベル0で停止する |
「MySQL」管理者の設定
「MySQL」の管理者であるroot(システム上のrootとは別)のパスワードを設定します。
Solaris# /usr/local/mysql/bin/mysql -u root <= 「MySQL」へrootでログイン
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.51-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select user,host,password from mysql.user; <= 「MySQL」のユーザのパスワードを確認
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | | <= パスワードがブランク
| root | Solaris | | <= パスワードがブランク
| root | 127.0.0.1 | | <= パスワードがブランク
| | localhost | |
| | Solaris | |
+------+-----------+----------+
5 rows in set (0.00 sec)
mysql> set password for root@localhost=password('設定するパスワード');
<= 「MySQL」上のrootユーザのパスワードを設定(接続元ホストがlocalhost)
mysql> set password for root@Solaris=password('設定するパスワード');
<= 「MySQL」上のrootユーザのパスワードを設定(接続元ホストがSolaris)
mysql> set password for root@127.0.0.1=password('設定するパスワード');
<= 「MySQL」上のrootユーザのパスワードを設定(接続元ホストが127.0.0.1)
mysql> exit <= 終了
|
ブランクユーザの削除
上記の「MySQL」の確認でuserとpasswordがブランクのユーザが確認されたので、削除する。
Solaris# /usr/local/mysql/bin/mysql -u root -prootのパスワード <= 「MySQL」にログイン mysql> delete from mysql.user where user=''; <= ブランクユーザの削除 |
一般ユーザの設定
データベースdb_testに対して全ての権限を持つユーザkazを作成する。
Solaris# /usr/local/mysql/bin/mysql -u root -prootのパスワード <= 「MySQL」にログイン mysql> grant all privileges on db_test.* to kaz@localhost identified by '設定するパスワード'; <= ユーザkazの作成(接続元ホストがlocalhost) |