新安裝的XAMPP訪問phpmyadmin出錯的解決方案_伺服器其它

來源:互聯網
上載者:User

XAMPP(Apache+MySQL+PHP+PERL)是一個功能強大的建 XAMPP 軟體站整合軟體包,輕巧,用起來很方便。它提供了強大的phpmyadmin資料庫管理工具,讓使用者對資料庫的使用和管理得心應手。對於不能在本地開啟phpmyadmin的問題,我的解決方案如下:

MySQL有一個預設的專用連接埠:3306,所以,如果你之前獨立安裝了MySQL,那麼3306連接埠已經被佔用。安裝XAMPP整合的MySQL時,必須重新設定獨立的連接埠,否則是不能訪問phpmyadmin的,我收到的報錯資訊見圖:

修改方法也很方便,開啟XAMPP的控制台,找到mysql右側的config,點擊,會出現my.ini的選擇項,這個就是mysql的設定檔了,如圖:

當然只是修改連接埠,我還是訪問不了。還要去修改phpmyadmin的設定檔,這裡有兩個途徑:

一、訪問phpmyadmin出錯的解決方案

1、開啟xampp目錄(預設的安裝目錄,如果修改,請找到xampp的安裝目錄),開啟phpmyadmin的目錄,在該目錄下找到config.inc.php,我的預設配置:

複製代碼 代碼如下:

<?php
/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'username';            //mysql使用者名稱
$cfg['Servers'][$i]['password'] = 'password';       //mysql密碼
$cfg['Servers'][$i]['extension'] = 'mysqli';     //擴充配置,若訪問出現沒有配置mysqli等錯誤,加上這個。預設是有的
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

/* Advanced phpMyAdmin features */
$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]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
$cfg['Servers'][$i]['recent'] = 'pma_recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';

/*
 * End of servers configuration
 */

?>

然後在$cfg['Lang'] = ”後加入以下代碼:

複製代碼 代碼如下:

$cfg['Servers'][$i]['port'] = '3307'

儲存,重啟apache,在地址欄輸入localhost/phpmyadmin,就可以直接進入phpmyadmin的管理介面了

這種方式不太安全,沒有驗證,誰都可以進入phpmyadmin管理資料庫了。重新回到設定檔,找到如下代碼:

複製代碼 代碼如下:

$cfg['Servers'][$i]['auth_type'] = 'config'

將上述代碼的config改為cookie,或者http,就會出現驗證介面了(cookie和http對應的驗證介面在windows上還不一樣),我把它改成了cookie,出現如圖驗證介面。

2、這種方式也是修改phpmyadmin的設定檔,不過路徑不一樣了,在phpmyadmin/libraries找到config.default.php檔案,裡麵包含了伺服器的各種配置參數。

 

複製代碼 代碼如下:

 $cfg['Servers'][$i]['port'] = '';
 

 找到這一行代碼,我的在132行,這個是配置連接埠的,值為空白則是預設的3306,將其值改為3307後,儲存,重啟apache,同樣可以訪問phpmyadmin了

 二、phpmyadmin設定檔詳解

開啟在phpmyadmin/libraries找到config.default.php檔案,常用參數配置如下:

複製代碼 代碼如下:

$cfg['PmaAbsoluteUri'] = '';  //phpmyadmin的訪問網址 ,預設就行
$cfg['TranslationWarningThreshold'] = 80; //伺服器連接埠
$cfg['Servers'][$i]['host'] = 'localhost';//mysql主機ip,如果mysql和該phpmyadmin在同一伺服器,則按預設localhost
$cfg['Servers'][$i]['port'] = '3307';  //mysql連接埠,預設3306,保留為空白即可
$cfg['Servers'][$i]['user'] = 'root'; //mysql使用者名稱
$cfg['Servers'][$i]['password'] = '';//密碼
$cfg['Servers'][$i]['auth_type'] = 'cookie'; //認證方式
/*連接埠、使用者名稱、認證方式等也可以再config.inc.php中配置,並且優先順序高
*$cfg['Servers'][$i]['auth_type'] = 'config';  這個是在config.inc.php的
*配置,若不修改這個值,仍然可以直接存取phpmyadmin
*/
$cfg['DefaultLang']='zh';  //設定預設語言

 對於認證方式$cfg['Servers'][$i]['auth_type'] = ‘cookie'; 的值有四個:cookie,http,HTTP,config

 config方式即輸入phpmyadmin的訪問網址即可直接進入,無需輸入使用者名稱和密碼,是不安全的,不推薦使用。

當該項設定為cookie,http或HTTP時,登入phpmyadmin需要資料使用者名稱和密碼進行驗證,,具體如下:

PHP安裝模式為Apache,可以使用http和cookie;

PHP安裝模式為CGI,可以使用cookie .

另外,在cookie模式下,還可以設定$cfg['blowfish_secret'] = ”; (短語密碼) ,至於設定為什麼密碼,由您自己決定,也可以不用理會。(沒測試過,這一點來自文檔說明,我覺得不用理會就行了)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.