- 论坛徽章:
- 0
|
急!!!phpMyAdmin认证的问题???
安裝phpMyAdmin
用root 登入,安裝這個套件
rpm -Uvh phpmyadmin-1-1.noarch.rpm
裝好後,輸入網址 http://主機的名稱或ip/phpMyAdmin/ 可以看到這樣的畫面:
這麼酷的管理介面,很方便吧。內定會把程式裝在 /home/httpd/html/phpMyAdmin/ 裡面
--------------------------------------------------------------------------------
密碼驗證
可惜好花不常開,知道網址的任一使用者,都可以透過瀏覽器,管理你的SQL資料庫,這.....太不安全了吧。
我們可以利用Apache提供的.htaccess存取限制功能,做簡易的使用者輸入密碼驗證。(聲明:這當然也不是很安全的做法),在/etc/httpd.conf 裡面,也要做好相關設定。
更換目錄 cd /home/httpd/html/phpMyAdmin
手動產生一個.htaccess 的隱藏檔
qe .htaccess (注意,.htaccess前面有一個點.,是隱藏檔)
檔案內加入以下文字
AuthName "private" //取一個名稱
AuthType Basic //基本驗證
AuthUserFile /security/user.pass //驗證用的密碼檔路徑
require user tester1 tester2 //指定誰可以使用
然後用htpasswd 製作密碼檔,這要和.htaccess中指定的密碼檔路徑/security/user.pass配合喔。
mkdir /security
htpasswd -c /security/user.pass tester1
輸入密碼兩次,確認tester1為使用者後,產生的密碼檔在 /security/user.pass
眼不見不信,一定要瞧一瞧去。
cat /security/user.pass
tester1:ERWH0CVHJWCS
果然遵照吩咐編密做好了。
再用瀏覽器,開啟phpMyAdmin,輸入網址 http://主機的名稱或ip/phpMyAdmin/
看到密碼認證的畫面了嗎??
輸入tester1這個user的帳號和密碼就可以進去了。
--------------------------------------------------------------------------------
變更mySQL 上 root 的密碼
原文請參閱 http://netlab.kh.edu.tw/newuser/Imp%20setup%20of%20RedHat%206_1%20CLE%200_9-2.htm
mysql mysql
(進入 MySQL 系統)
mysql>;
(mySQL的提示符號,有點像dos,接下來就都要下指令了)
mysql>; update user set password=password('123456') where user='root';
(修改 root 之密碼,最後都要加上分號)
mysql>; delete from user where User = '';
( 刪除系統 "附贈" 的空白帳號,以策安全) ''→是兩個單引號
mysql>; flush privileges;
( 更新回寫資料庫 )
註:89/11/10更正 privileges 拼字錯誤,感謝Snoopy兄<
snoopy347@pchome.com.tw >;指正
mysql>; exit
(離開mySQL系統)
用新設定的 root密碼登入系統,以確定 root 密碼修改成功。
mysql mysql -uroot -p123456
(-u 和 root 之間沒有空白,-p和密碼之間也沒有空白。)
mysql>;
(mySQL的提示符號,成功進入 MySQL)
mysql>;exit
(離開系統)
改過mySQL root 的密碼,記得在 /home/httpd/html/phpMyAdmin/config.inc.php3 中的前幾行也要把空白密碼改成你的密碼。
qe /home/httpd/html/phpMyAdmin/config.inc.php3
<?php
/* $Id: config.inc.php3,v 1.26 1999/10/10 19:57:29 tobias Exp $ */
/*
* phpMyAdmin Configuration File
* All directives are explained in Documentation.html
*/
// The $cfgServers array starts with $cfgServers[1]. Do not use $cfgServers[0].
// You can disable a server config entry by setting host to ''.
$cfgServers[1]['host'] = 'localhost'; // MySQL hostname
$cfgServers[1]['port'] = ''; // MySQL port - leave blank for default port
$cfgServers[1]['adv_auth'] = false; // Use advanced authentication?
$cfgServers[1]['stduser'] = 'root'; // MySQL standard user (only needed with advanced auth)
$cfgServers[1]['stdpass'] = ''; // MySQL standard password (only needed with advanced auth)
$cfgServers[1]['user'] = 'root'; // MySQL user (only needed with basic auth)
$cfgServers[1]['password'] = '123456'; // MySQL password (only needed with basic auth) |
|