FreeBSD/MySQL/phpMyAdmin

phpMyAdmin

dokuwiki.fl8.jp転載済

WebブラウザからMySQLデータベースを管理するためのPHPで記述されたソフトウェアです。

phpMyAdminを使用してWebブラウザからMySQLのテーブル操作、インポート・エクスポートすることが出来ます。

環境

ダウンロード

phpMyAdmin Projectより最新版をダウンロード。

インストール

展開

Web上から表示できる場所に展開するとよいと思います。

$ tar zxvf phpMyAdmin-2.9.2-all-languages.tar.gz
$ mv phpMyAdmin-2.9.2-all-languages phpMyAdmin
$ cp config.sample.inc.php config.inc.php

設定変更

$ vi config.ini.php
--------------------変更箇所-----------------------
38 $cfg['Servers'][$i]['controluser'] = 'pmausr';
39 $cfg['Servers'][$i]['controlpass'] = 'pmapass';

                     ↓
38 $cfg['Servers'][$i]['controluser'] = '';
39 $cfg['Servers'][$i]['controlpass'] = '';

------------------何かパスワードを設定------------
17 $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

これでmysqlに設定してあるユーザ名・パスワードでログインできます。

確認

ウェブ上から確認。

http://*******/phpMyAdmin

最新のバージョンだとlibmcryptが無いと怒られる

# cd /usr/ports/security/libmcrypt
# make install clean

・PHPを下記の--with-mysql=/usr/localを加えて再インストール
./configure  --with-mysql=/usr/local \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-pear --with-tsrm-pth --with-mcrypt=/usr/local \
--with-gd --with-zlib --with-ttf=/usr/local \
--with-freetype-dir=/usr/local --with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local --enable-force-cgi-redirect \
--enable-mbstring --enable-mbstr-enc-trans \
--enable-trans-sid --enable-versioning --enable-gd-native-ttf --enable-gd-jis-conv

デフォルトでログインするように設定する。

デフォルトでログインするユーザ名:パスワードを設定する。
auth_typeをconfigに変更する。

# cd phpMyAdmin
# cp config.sample.inc.php config.inc.php
# vi config.inc.php
下記を追加
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'hogehoge';
$cfg['Servers'][$i]['auth_type'] = 'config';

この場合アクセスするだけで、ログインできてしまうのでBasic認証をかけておく

# cd phpMyAdmin
# vi .htaccess 
AuthUserFile   /home/www/public_html/phpMyAdmin/.htpasswd
AuthGroupFile   /dev/null
AuthName        "Please Enter Your Password"
AuthType        Basic
Require valid-user

パスワードファイルの作成

# htpasswd -c .htpasswd hogehoge
New password: 
Re-type new password: 
Adding password for user hogehoge

アクセスできるDBを設定する。

199  * @global string $cfg['Servers'][$i]['only_db']
200  */
201 $cfg['Servers'][$i]['only_db'] = 'shinbutsu';