MySQL 管理ツールの導入 [phpMyAdmin]

Web ベースの MySQL 管理ツールである phpMyAdmin を導入する手順を説明します。

インストール

1. phpMyAdmin をインストールします。

# yum -y install phpMyAdmin
Loading "fastestmirror" plugin
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Loading mirror speeds from cached hostfile
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for phpMyAdmin to pack into transaction set.
phpMyAdmin-2.10.0.2-3.fc6 100% |=========================|  82 kB    00:00
---> Package phpMyAdmin.noarch 0:2.10.0.2-3.fc6 set to be updated
--> Running transaction check
--> Processing Dependency: php-mysql >= 4.1.0 for package: phpMyAdmin
--> Processing Dependency: php-mbstring >= 4.1.0 for package: phpMyAdmin
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-mbstring to pack into transaction set.
php-mbstring-5.1.6-3.6.fc 100% |=========================|  16 kB    00:00
---> Package php-mbstring.i386 0:5.1.6-3.6.fc6 set to be updated
---> Downloading header for php-mysql to pack into transaction set.
php-mysql-5.1.6-3.6.fc6.i 100% |=========================|  17 kB    00:00
---> Package php-mysql.i386 0:5.1.6-3.6.fc6 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 phpMyAdmin              noarch     2.10.0.2-3.fc6   extras            4.1 M
Installing for dependencies:
 php-mbstring            i386       5.1.6-3.6.fc6    updates           968 k
 php-mysql               i386       5.1.6-3.6.fc6    updates            83 k

Transaction Summary
=============================================================================
Install      3 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 5.1 M
Downloading Packages:
(1/3): phpMyAdmin-2.10.0. 100% |=========================| 4.1 MB    00:04
(2/3): php-mbstring-5.1.6 100% |=========================| 968 kB    00:01
(3/3): php-mysql-5.1.6-3. 100% |=========================|  83 kB    00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: php-mysql                    ######################### [1/3]
  Installing: php-mbstring                 ######################### [2/3]
  Installing: phpMyAdmin                   ######################### [3/3]

Installed: phpMyAdmin.noarch 0:2.10.0.2-3.fc6
Dependency Installed: php-mbstring.i386 0:5.1.6-3.6.fc6 php-mysql.i386 0:5.1.6-3.6.fc6
Complete!

Apache 設定

1. phpMyAdmin 用の Apache 設定ファイルを編集します。

# 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
<Directory /usr/share/phpMyAdmin/>
   order deny,allow
   deny from all
   LAN 環境からのみアクセス可能とします。
   allow from 127.0.0.1 192.168.11
</Directory>

# This directory does 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>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.
#
<IfModule mod_security.c>
    <LocationMatch "/phpMyAdmin/(.+)">
        SecFilterInheritance Off
    </LocationMatch>
</IfModule>

2. Apache の設定変更に間違いがないか検証します。

# apachectl configtest
Syntax OK

3. Apache 設定を再読み込みします。

# service httpd reload
Reloading httpd:                                           [  OK  ]

設定

1. 必要により phpMyAdmin 設定ファイルを編集します。

# vi /etc/phpMyAdmin/config.inc.php

http://サーバー名/phpMyAdmin/ へアクセスします。
ログインには MySQL へログインする時のユーザ名とパスワードでログインします。

Google