top
Loading...
安裝并使用phpMyAdmin管理MySQL數據庫

如果使用合適的工具,MySQL數據庫的管理就會為得相當簡單。應用MySQL命令行方式需要對MySQL知識非常熟悉,對SQL語言也是同樣的道理。不僅如此,如果數據庫的訪問量很大,列表中數據的讀取就會相當困難。

當前出現很多GUI MySQL客戶程序,其中最為出色的是基于Web的phpMyAdmin工具。這是一種MySQL數據庫前臺的基于PHP的工具。PhpMyAdmin的缺點是必須安裝在你的Web服務器中,所以如果沒有合適的訪問權限,其它用戶有可能損害到你的SQL數據。

PhpMyAdmin的安裝過程非常簡單。從http://www.phpmyadmin.net/下載PhpMyAdmin,當前最新版本是2.6.4-pl3。將下載文件解壓縮到你選擇的路徑,比如/srv/www/domain.com/html/admin。在將phpMyAdmin與數據庫連接之前,請確保phpMyAdmin處于受保護狀態,其中可以通過建立一個an .htaccess文件來完成:


AuthUserFile /srv/www/domain.com/.htpasswd
AuthGroupFile /dev/null
AuthName adminAuthType basic

Order Deny,Allow
Deny From All
Allow From localhost
require user admin
satisfy any

以上代碼段使得假設路徑/srv/www/domain.com沒有受保護因此.htaccess文件處于Web路徑之外(比如Apache中的DocumentRoot為/srv/www/domain.com/html)。使用htpasswd工具建立/srv/www/domain.com/.htpasswd文件:Create the /srv/www/domain.com/.htpasswd file using the htpasswd tool:


# htpasswd -cm /srv/www/domain.com/.htpasswd admin

一旦你已經提供了管理員的密碼,可以編輯包含phpMyAdmin 的config.inc.php文件。你將可以編輯$cfg['PmabsoluteUri']關鍵字以指向安裝在服務器中phpMyAdmin的位置,然后編輯$cfg['Servers']數組。為了快速建立和運行,并且能夠編輯服務器上所有的數據庫,你將需要提供的權限證明:


$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';$cfg['Servers'][$i]['password'] = 'mysecretrootpass';

現在你可以進入http://www.domain.com/admin/phpMyAdmin-2.6.4-pl3/并訪問你的MySQL數據,并可將路徑重命名為phpMyAdmin/以更為方便的訪問。
(e129)

作者:http://www.zhujiangroad.com
來源:http://www.zhujiangroad.com
北斗有巢氏 有巢氏北斗