02.SQLサーバー
◆SQLサーバー
WordPressを利用するにはSQLサーバーが必要になります。
そこで、SQLサーバーのインストールと設定を行います。
◆MySQLサーバーのインストール
Fedora のインストール時 “MySQLデータベース” を選択していればmysql はインストールされています。
もし、Fedora のインストール時 “MySQLデータベース”を選択していない場合は下記要領でインストールして下さい。
[root@linux]# yum -y install mysql-server ← 入力
◆MySQLサーバーの起動
[root@linux]# /etc/rc.d/init.d/mysqld start ← 入力
続いてPCの再起動に mysqld を自動的に起動するようにします。
[root@linux]# chkconfig mysqld on ← 入力
自動起動設定の確認
[root@linux]# chkconfig –list mysqld ← 入力
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
◆MySQLサーバーの設定
MySQLサーバーに root でログインします。
[root@linux]# mysql -u root← 入力
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2 to server version: 5.0.22
Type ‘help;’ or ‘\h’ for help.
Type ‘\c’ to clear the buffer.
mysql>
まずは root のパスワード設定です。
mysql> elect user,host,password from mysql.user;← 入力
+======+==============+==========+
| user | host | password |
+======+==============+==========+
| root | localhost | |← パスワードが無い
| root | linux.server | |← パスワードが無い
| | linux.server | |
| | localhost | |
+======+==============+==========+
4 rows in set (0.00 sec)
上記のようにパスワードが設定されていません。
locaihost の root のパスワードを設定します。
mysql> set password for root@’localhost’=password(‘******’);← 入力
Query OK, 0 rows affected (0.00 sec) ↑ ****** はパスワード
host 名の root のパスワードを設定します。
mysql> set password for root@’linux.server’=password(‘******’);← 入力
Query OK, 0 rows affected (0.00 sec) ↑ ****** はパスワード
パスワードの設定確認をします。
mysql> select user,host,password from mysql.user;← 入力
+======+==============+===========+
| user | host | password |
+======+==============+===========+
| root | localhost | ********* |← パスワードが設定された
| root | linux.server | ********* |← パスワードが設定された
| | linux.server | |
| | localhost | |
+======+==============+===========+
4 rows in set (0.00 sec)
次に匿名ユーザーを削除します。
上記の表の userの欄に空白の部分がありますが、これが匿名ユーザーです。セキュリティ上問題がありますので削除します。
mysql> delete from mysql.user where user=”; ← 入力
Query OK, 2 rows affected (0.00 sec)
匿名ユーザーを削除できたか確認します。
mysql> select user,host,password from mysql.user; ← 入力
+======+==============+==============+
| user | host | password |
+======+==============+==============+
| root | localhost | ************ |← 匿名ユーザーが消えた
| root | linux.server | ************ |
+======+==============+==============+
2 rows in set (0.47 sec)
匿名ユーザーを削除できました。
次に不要なデータベースを削除します。
MySQLサーバーには最初から test と言うデータベースが登録されています。これは不要なので削除します。
まずはデータベースの確認です。
mysql> show databases; ← 入力
+====================+
| Database |
+====================+
| mysql |
| test |← 不要なデータベース test
+====================+
2 rows in set (0.00 sec)
次にデータベースを削除します。
mysql> drop database test; ← 入力
削除の確認です。
mysql> show databases; ← 入力
+====================+
| Database |
+====================+
| mysql |
+====================+
1 rows in set (0.00 sec)
以上で設定は終了です。
ここで MySQL サーバーよりログアウトします。
mysql> exit ← 入力
Bye
ここからは上記でパスワードを設定したのパスワードを入力しないとログインできません。
[root@linux]# mysql -u root -p****** ← 入力 ( ****** はパスワード )
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.22
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>
*************************
WorsPress メニューに戻る