自宅サーバー ≫ Linux Server ≫ CentOS 7 ≫ データベースサーバー(mariadb + phpMyAdmin)

 
MariaDB のインストール
CentOS 7 よりデータベースサーバーが MySQL から MariaDB に変更なった
 
 
[root@centos]# yum -y install mariadb-server
 
文字コードの設定
 
 [root@
centos]# vi /etc/my.cnf.d/server.cnf
 #
 # These groups are read by MariaDB server.
 # Use it for options that only the server (but not clients) should see
 #
 # See the examples of server my.cnf files in /usr/share/mysql/
 #

 # this is read by the standalone daemon and embedded servers
 [server]

 # this is only for the mysqld standalone daemon
 [mysqld]
 
character-set-server = utf8   <--- 追記

 # this is only for embedded server
 [embedded]

 # This group is only read by MariaDB-5.5 servers.
 # If you use the same .cnf file for MariaDB of different versions,
 # use this group for options that older servers don't understand
 [mysqld-5.5]

 # These two groups are only read by MariaDB servers, not by MySQL.
 # If you use the same .cnf file for MySQL and MariaDB,
 # you can put MariaDB-only options here
 [mariadb]

 [mariadb-5.5]

 
MariaDB の起動

 
[root@centos]# systemctl start mariadb
 
PCの再起動に mariadb を自動的に起動するように設定
 
 [root@
centos]# systemctl enable mariadb
 
自動起動設定の確認
 
 [root@
centos]# systemctl list-unit-files | grep mariadb
 mariadb.service                               enabled
   <--- enabled になっていればOK
 
MariaDB の設定
 
 [root@
centos]# mysql_secure_installation
 
/usr/bin/mysql_secure_installation: 行 379: find_mysql_client: コマンドが見つかりません

 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
       SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

 In order to log into MariaDB to secure it, we'll need the current
 password for the root user. If you've just installed MariaDB, and
 you haven't set the root password yet, the password will be blank,
 so you should just press enter here.

 Enter current password for root (enter for none):
   <--- 空白まま Enter を押す
 OK, successfully used password, moving on...

 Setting the root password ensures that nobody can log into the MariaDB
 root user without the proper authorisation.

 Set root password? [Y/n]
   <--- 空白まま Enter を押す(root のパスワード設定)
 New password:********  
   <--- パスワードの入力
 Re-enter new password:
********
 
   <--- 再度パスワードの入力
 Password updated successfully!
 Reloading privilege tables..
 ... Success!


 By default, a MariaDB installation has an anonymous user, allowing anyone
 to log into MariaDB without having to have a user account created for
 them. This is intended only for testing, and to make the installation
 go a bit smoother. You should remove them before moving into a
 production environment.

 Remove anonymous users? [Y/n
   <--- 空白まま Enter を押す(匿名ユーザーの削除)
 ... Success!

 Normally, root should only be allowed to connect from 'localhost'. This
 ensures that someone cannot guess at the root password from the network.

 Disallow root login remotely? [Y/n]  
   <--- 空白まま Enter を押す(リモートからのrootログイン禁止)
 ... Success!

 By default, MariaDB comes with a database named 'test' that anyone can
 access. This is also intended only for testing, and should be removed
 before moving into a production environment.

 Remove test database and access to it? [Y/n]  
   <--- 空白まま Enter を押す(不要なデータベース
 - Dropping test database...                                      
                       test の削除)
 ... Success!
 - Removing privileges on test database...
 ... Success!

 Reloading the privilege tables will ensure that all changes made so far
 will take effect immediately.

 Reload privilege tables now? [Y/n
]      <--- 空白まま Enter を押す
 ... Success!

 Cleaning up...

 All done! If you've completed all of the above steps, your MariaDB
 installation should now be secure.

 Thanks for using MariaDB!

 
MariaDB の確認
 
 [root@
centos]# mysql -u root -p********   (******** はパスワード)
 Welcome to the MariaDB monitor. Commands end with ; or \g.
 Your MariaDB connection id is 14
 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 | *
1234567890abcdefghijklmnopqrstuvwxyz |
 | root | 127.0.0.1 | *
1234567890abcdefghijklmnopqrstuvwxyz |
 | root | ::1       | *
1234567890abcdefghijklmnopqrstuvwxyz |
 +------+-----------+---------------------------------------+
 3 rows in set (0.00 sec)

 MariaDB [(none)]>
select host,user from mysql.user;
   <--- 入力(ユーザー確認)
 +-----------+------+
 | host      | user |
 +-----------+------+
 | 127.0.0.1 | root |
 | ::1       | root |
 | localhost | root |
 +-----------+------+
 3 rows in set (0.00 sec)

 MariaDB [(none)]>
show databases;
   <--- 入力(データベース確認)
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | mysql              |
 | performance_schema |
 +--------------------+
 3 rows in set (0.03 sec)
 
 MariaDB [(none)]>
show variables like '%char%';
   <--- 入力(文字コード確認)
 +--------------------------+----------------------------+
 | Variable_name            | Value                      |
 +--------------------------+----------------------------+
 | character_set_client     | utf8                       |
 | character_set_connection | utf8                       |
 | character_set_database   | utf8                       |
 | character_set_filesystem | binary                     |
 | character_set_results    | utf8                       |
 | character_set_server     | utf8                       |
 | character_set_system     | utf8                       |
 | character_sets_dir       | /usr/share/mysql/charsets/ |
 +--------------------------+----------------------------+
 8 rows in set (0.01 sec)

 MariaDB [(none)]>
exit
   <--- 入力(確認終了)
 
phpmyadmin のインストール
CentOS7 の標準リポジトリでは phpmyadmin が ないため EPEL リポジトリにある phpmyadmin をインストールする
EPEL を利用できるようにするには本サイトの yum用リポジトリの追加 を参照
 
 [root@
centos]# yum -y --enablerepo=epel install phpmyadmin
 
設定
apache のバージョンによって設定場所が違うのでバージョンを確認
 
 [root@
centos]# httpd -v
 Server version: Apache/2.4.6 (CentOS)
 Server built: Apr 20 2018 18:10:38

 
apache のバージョン = 2.4.6

 
[root@centos]# vi /etc/httpd/conf.d/phpMyAdmin.conf
 # phpMyAdmin - Web based MySQL browser written in php
 #
 # Allows only localhost by default
 #
 # But allowing phpMyAdmin to anyone other than localhost should be considered
 # dangerous unless properly secured by SSL

 Alias /phpMyAdmin /usr/share/phpMyAdmin
 Alias /phpmyadmin /usr/share/phpMyAdmin

 <Directory /usr/share/phpMyAdmin/>
    AddDefaultCharset UTF-8

    <IfModule mod_authz_core.c>
      # Apache 2.4
   <--- apache のバージョンが 2.4 系の場合の設定場所
      <RequireAny>
        Require ip 127.0.0.1
        Require ip ::1
       
Require ip 192.168.1.   <--- 追記
      </RequireAny>
    </IfModule>
    <IfModule !mod_authz_core.c>
      # Apache 2.2
   <--- apache のバージョンが 2.2 系の場合の設定場所
      Order Deny,Allow
      Deny from All
      Allow from 127.0.0.1
      Allow from ::1
     
Allow from 192.168.1.   <--- 追記
    </IfModule>
 </Directory>

 <Directory /usr/share/phpMyAdmin/setup/>
    <IfModule mod_authz_core.c>
      # Apache 2.4
      <RequireAny>
        Require ip 127.0.0.1
        Require ip ::1
 
      </RequireAny>
    </IfModule>
    <IfModule !mod_authz_core.c>
      # Apache 2.2
      Order Deny,Allow
      Deny from All
      Allow from 127.0.0.1
      Allow from ::1
 
    </IfModule>
 </Directory>

 # These directories do not require access over HTTP - taken from the original
 # phpMyAdmin upstream tarball
 #
 <Directory /usr/share/phpMyAdmin/libraries/>
     Order Deny,Allow
     Deny from All
     Allow from None
 </Directory>

 <Directory /usr/share/phpMyAdmin/setup/lib/>
     Order Deny,Allow
     Deny from All
     Allow from None
 </Directory>

 <Directory /usr/share/phpMyAdmin/setup/frames/>
     Order Deny,Allow
     Deny from All
     Allow from None
 </Directory>

 # This configuration prevents mod_security at phpMyAdmin directories from
 # filtering SQL etc. This may break your mod_security implementation.
 #
 #<IfModule mod_security.c>
 #    <Directory /usr/share/phpMyAdmin/>
 #        SecRuleInheritance Off
 #    </Directory>
 #</IfModule>
 
Apache の再起動
設定を反映させるように Apache を再読込
 
 [root@
centos]# systemctl restart httpd   <--- 入力
 
phpMyAdmin の起動
インターネットブラウザを起動してアドレス欄にサーバーのアドレスの後に /phpmyadmin と追加して入力(http://192.168.1.**/phpmyadmin)

下図のような画面が表示されますので『ユーザー名:』&『パスワード:』に MySQL で設定したユーザー名&パスワードを入力して『実行する』をクリック

下図のようなページが画面が開くので必要に応じて設定

メッセージへの対処
下図のようにメッセージがトップページの下部に表示される事への対処

これは『 phpMyAdmin の翻訳が不完全なので協力して下さい。』との事なので、その気がある方は協力してあげてください
ちなみに『言語-Language』を『 English 』に変更して phpMyAdmin にログインし直すと注意メッセージは消えています

戻る