1 views

実現する機能

データベースサーバーは、サーバー上のデータベースをクライアントから操作できるようにするためのサーバー。WordPressもデータベースを使う必要があるので、ここでは、リレーショナル型データベースのデータベースサーバーであるMariaDBの導入手順を紹介します。MySQLがどうなるのかは気になるところですが、とりあえずはWordPressが動けば個人的には問題ありません。

MariaDBの導入手順

(1)MariaDBのインストール

[root@ufuso ~]# yum -y install mariadb-server ← mariadb-serverインストール
インストール:
  mariadb-server.x86_64 1:5.5.37-1.el7_0                                        

依存性関連をインストールしました:
  mariadb.x86_64 1:5.5.37-1.el7_0                                               
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7                                  
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7                                   
  perl-DBD-MySQL.x86_64 0:4.023-5.el7                                           
  perl-DBI.x86_64 0:1.627-4.el7                                                 
  perl-IO-Compress.noarch 0:2.061-2.el7                                         
  perl-Net-Daemon.noarch 0:0.48-5.el7                                           
  perl-PlRPC.noarch 0:0.2020-14.el7                                             

完了しました!

(2)MariaDBの起動

[root@ufuso ~]# systemctl start mariadb ← mariadb起動

[root@ufuso ~]# systemctl enable mariadb ← mariadb自動起動設定
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

(3)MariaDBの動作確認

[root@ufuso ~]# mysql -u root ← MySQL?へログイン
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select user,host,password from mysql.user; ← ホストの一覧表示
+------+--------------+----------+
| user | host         | password |
+------+--------------+----------+
| root | localhost    |          |
| root | ufuso.dip.jp |          |
| root | 127.0.0.1    |          |
| root | ::1          |          |
|      | localhost    |          |
|      | ufuso.dip.jp |          |
+------+--------------+----------+
6 rows in set (0.00 sec)

MariaDB [(none)]> set password for root@localhost=password('your-password');
 ← localhostのrootのパスワード設定
Query OK, 0 rows affected (0.02 sec)

MariaDB [(none)]> delete from mysql.user where user=''; ← ユーザーのいない(匿
名)ホストを削除
Query OK, 2 rows affected (0.07 sec)

MariaDB [(none)]> select user,host,password from mysql.user; ← ホストの一覧表
示で変更内容を確認
+------+--------------+-------------------------------------------+
| user | host         | password                                  |
+------+--------------+-------------------------------------------+
| root | localhost    | *E8C3535F8B8516B041FE2FFBA079615EAA366120 |
| root | ufuso.dip.jp |                                           |
| root | 127.0.0.1    |                                           |
| root | ::1          |                                           |
+------+--------------+-------------------------------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> exit ← MySQLの終了
Bye

[root@ufuso ~]# mysql -u root -p ← MySQLへrootでログイン
Enter password:  ← MySQLのrootパスワード応答
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database test; ← testという名でデータベースが作成でき
るか確認。
Query OK, 1 row affected (0.07 sec)

MariaDB [(none)]> grant all privileges on test.* to tu@localhost identified by 'password';
 ← testというデータベースに読み書き権限を持った(grant all privileges)ユーザー
tuをパスワードpasswordで設定できるか確認。
Query OK, 0 rows affected (0.40 sec)

MariaDB [(none)]> select user,host,password from mysql.user; ← ホストの一覧表示
で変更内容を確認
+------+--------------+-------------------------------------------+
| user | host         | password                                  |
+------+--------------+-------------------------------------------+
| root | localhost    | *E8C3535F8B8516B041FE2FFBA079615EAA366120 |
| root | ufuso.dip.jp |                                           |
| root | 127.0.0.1    |                                           |
| root | ::1          |                                           |
| tu   | localhost    | *E8C3535F8B8516B041FE2FFBA079615EAA366120 |
+------+--------------+-------------------------------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> drop database test; ← testデータベースを削除できるか確認。
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show databases; ← データベースを削除できたか一覧表示で確認。
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)

MariaDB [(none)]> exit ← MySQLを終了。
Bye

[root@ufuso ~]# setsebool -P httpd_can_network_connect_db 1 ← SELinuxが有効
ならhttpd_can_network_connect_dbをonにする。1を入力してonにする方法もある(1=on、
0=offの意味)

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください