狐的窩

跳到主文

享受生活

部落格全站分類:圖文創作

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 8月 05 週五 201101:53
  • MySQL管理工具(phpMyAdmin)

說到MySQL管理工具,phpMyAdmin是免費及最常用的工具了,由PHP寫成,所有資料庫管理、備份、回存、SQL操作都可以由此工具完成。


安裝 phpMyAdmin
1. 請至官方網站下載最新版本。
2. 將下載的檔案解壓縮至WEBROOT目錄(D:\WebServer\wwwroot)。
3. 複製config.sample.inc.php成config.inc.php。
4. 修改config.inc.php
   cfg['Servers'][i]['auth_type'] = 'http';  /* cookie改成http */
   cfg['Servers'][i]['AllowNoPassword'] = true;  /*要改成true,因為MySQL root預設為空白 */
5. 輸入 http://localhost:8081/phpmyadmin/index.php ,就可以進入phpmyadmin來管理MySQL了。


雖然順利登入了,網頁畫面往下拉,phpmyadmin會把現有的問題顯示出來。
A. 有新的phpmyadmin可用,請考慮升級。
   這不是太大的問題,要更新時到官方網站下載新版本就行了,往後常會遇到,千萬記得備份你的config.inc.php檔案。
B. phpmyadmin高級功能未全部設置,部分功能不可用。
   解決方式都可以在PmaWiki找到
   a. 新增control user
    GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
    GRANT SELECT (
        Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
        Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
        File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
        Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
        Execute_priv, Repl_slave_priv, Repl_client_priv
        ) ON mysql.user TO 'pma'@'localhost';
    GRANT SELECT ON mysql.db TO 'pma'@'localhost';
    GRANT SELECT ON mysql.host TO 'pma'@'localhost';
    GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)

   b. 執行create_tables.sql,檔案位於phpMyAdmin\scripts目錄下。
   c. 授與權限
    GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost';
   d. 修改config.inc.php,把以下設定前面//都拿掉就可以了
    /* User used to manipulate with storage */
    cfg['Servers'][i]['controluser'] = 'pma';
    cfg['Servers'][i]['controlpass'] = 'pmapass';

    /* Storage database and tables */
    cfg['Servers'][i]['pmadb'] = 'phpmyadmin';
    cfg['Servers'][i]['bookmarktable'] = 'pma_bookmark';
    cfg['Servers'][i]['relation'] = 'pma_relation';
    cfg['Servers'][i]['table_info'] = 'pma_table_info';
    cfg['Servers'][i]['table_coords'] = 'pma_table_coords';
    cfg['Servers'][i]['pdf_pages'] = 'pma_pdf_pages';
    cfg['Servers'][i]['column_info'] = 'pma_column_info';
    cfg['Servers'][i]['history'] = 'pma_history';
    cfg['Servers'][i]['tracking'] = 'pma_tracking';
    cfg['Servers'][i]['designer_coords'] = 'pma_designer_coords';
    cfg['Servers'][i]['userconfig'] = 'pma_userconfig';

   e. 記得重啟apache來讓設定生效,重啟是最保險的方式。
   Note:執行完create_tables.sql 還一直顯示有問題,請清session file

C. 您配製文件中的配置(空密碼的root)... ,主要說沒設置密碼容易被入侵,請設置密碼。
   照以前的版本,應該是蠻容易完成一件事,可是試了最近的幾個版本,都一直無效。
   從一般設定/修改密碼去設定完成後,我用mysqladmin去驗證,一樣還是不需要密碼,就可以登入了,不管是用MySQL 4.0或MySQL 4.1x的加密方式,就是無效。就只好用mysql本身提供的工具來完成這件事了。
   D:\WebServer\mysql\bin>mysql -u root
   Welcome to the MySQL monitor. Commands end with ; or \g.
   Your MySQL connection id is 8
   Server version: 5.5.14-log MySQL Community Server (GPL)

   Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

   Oracle is a registered trademark of Oracle Corporation and/or its
   affiliates. Other names may be trademarks of their respective
   owners.

   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

   mysql>use mysql; (切換資料庫)
   Database changed
   mysql> update user set password=password('yourpasswordhere') where user='root'; (更新密碼)
   Query OK, 0 rows affected (0.01 sec)
   Rows matched: 3 Changed: 0 Warnings: 0
   mysql> DELETE FROM user WHERE User=''; (刪除空帳號,維護系統安全)
   Query OK, 1 row affected (0.00 sec)
   mysql> FLUSH PRIVILEGES; (即時更新上面設定)
   Query OK, 0 rows affected (0.00 sec)
   mysql> quit;
   Bye

D. 你的PHP MySQL 版本和 MySQL伺服器版本不合。
   基本上不用太擔心這個,PHP預設是5.x版,已經夠使用了。

這時你的phpmyadmin基本上應該都是頭好壯壯,沒其他大問題。

其他常見問題
1. 正體中文
   新出的版本都沒有正體中文,所以當phpmyadmin再抓OS預設語言時,就會以簡體中文顯示,這時就算你將config.inc.php檔案中的預設語言改成 cfg['DefaultLang'] = 'zh_TW' 一樣不會有任何作用,請至網站下載(ok 3.4.2) Traditional Chinese translation for 3.4.x,並將下載回來的檔案放置WebROOT底下phpMyAdmin\locale\zh_TW\LC_MESSAGES目錄中。

2. 使用cookie方式登入時,常會出現下圖錯誤。


請確認php.ini內有將extension=php_mcrypt.dll打開,並確定啟動apache時,php能順利帶起mcrypt這模組。

3. session問題


3.1 請檢查php.ini中session.save_path設定的路徑,並確保有權限存取此目錄。
3.2 將下列語法存成session_test.php,可以用來檢查session相關所有訊息。
<?php
ini_set('display_errors', 'On');
error_reporting(6143);

session_start();

sessionSavePath = ini_get('session.save_path');

echo '<br><div style="background:#def;padding:6px">'
   , 'If a session could be started successfully <b>you should'
   , ' not see any Warning(s)</b>, otherwise check the path/folder'
   , ' mentioned in the warning(s) for proper access rights.<hr>';

if (empty(sessionSavePath)) {
   echo 'A "<b>session.save_path</b>" is currently',
      ' <b>not</b> set.<br>Normally "<b>';
   if (isset(_ENV['TMP'])) {
      echo _ENV['TMP'], '</b>" (_ENV["TMP"]) ';
   } else {
      echo '/tmp</b>" or "<b>C:\tmp</b>" (or whatever',
         ' the OS default "TMP" folder is set to)';
   }
   echo ' is used in this case.';
} else {
   echo 'The current "session.save_path" is "<b>',
      sessionSavePath, '</b>".';
}

echo '<br>Session file name: "<b>sess_', session_id()
   , '</b>".</div><br>';
?>

當所有session設定檢查無誤,應會出現類似下面畫面結果。



文章標籤
全站熱搜
創作者介紹
創作者 mark528 的頭像
mark528

狐的窩

mark528 發表在 痞客邦 留言(0) 人氣(120,325)

  • 全站分類:
  • 個人分類:MySQL
▲top

文章搜尋

好康資訊

熱門文章

  • ()MySQL管理工具(phpMyAdmin)
  • ()SQL語法查詢結果去除重複性資料
  • ()Oracle與日期有關的常用函數
  • ()[java] String.split()用法
  • ()在Windows安裝php開發環境
  • ()如何在Mac電腦格式化SD卡
  • ()SQL 語法如何將多欄位查詢結果合併成一個字串
  • ()[資料庫] SQL Server Expres(SQL Server免費版本)
  • ()如何查詢SQL Server目前連線數
  • ()iPhone:減少按 Home 鍵的次數,iOS 5新增功能提供虛擬按鈕,延長 Home 鍵壽命

文章分類

toggle 網路資源 (2)
  • 圖像和圖示 (0)
  • 網路空間應用 (0)
toggle 軟體應用 (5)
  • excel (0)
  • 虛擬軟體 (0)
  • CentOS (0)
  • iphone (0)
  • Windows 8 (0)
toggle 手工物製作 (3)
  • 手帳 (0)
  • PaperCraft (0)
  • 模型 (0)
toggle 程式設計 (15)
  • Shell Script (0)
  • Perl (0)
  • PHP (0)
  • WebPI (0)
  • ASP.NET (0)
  • C# (0)
  • Windows Scripting Host (0)
  • Web (0)
  • 專案管理 (0)
  • JSP (0)
  • Java (0)
  • Visual C (0)
  • HTML (0)
  • Windows 8 (0)
  • Websphere (0)
toggle 學習心得 (3)
  • PMP (0)
  • 學習心得 (0)
  • 讀書心得 (0)
toggle 資料庫 (5)
  • PostgreSQL (0)
  • Oracle (0)
  • MySQL (0)
  • SQL Server (0)
  • DB2 (0)
toggle 生活綜合 (2)
  • 生活資訊 (0)
  • 生活雜記 (0)
  • 未分類文章 (1)

文章精選

個人資訊

mark528
暱稱:
mark528
分類:
圖文創作
好友:
累積中
地區:

參觀人氣

  • 本日人氣:0
  • 累積人氣:1,045,810
mark528
PIXNET Logo登入