新安裝的XAMPP訪問phpmyadmin出錯的解決方法

XAMPP(Apache+MySQL+PHP+PERL)是一個功能強大的建 XAMPP 軟件站集成軟件包,輕巧,用起來很方便。它提供了強大的phpmyadmin數(shù)據(jù)庫管理工具,讓使用者對數(shù)據(jù)庫的使用和管理得心應(yīng)手。對于不能在本地打開phpmyadmin的問題,我的解決方案如下:
MySQL有一個默認的專用端口:3306,所以,如果你之前獨立安裝了MySQL,那么3306端口已經(jīng)被占用。安裝XAMPP集成的MySQL時,必須重新設(shè)置獨立的端口,否則是不能訪問phpmyadmin的,我收到的報錯信息見圖:

修改方法也很方便,打開XAMPP的控制面板,找到mysql右側(cè)的config,點擊,會出現(xiàn)my.ini的選擇項,這個就是mysql的配置文件了,如圖:

當(dāng)然只是修改端口,我還是訪問不了。還要去修改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'; //擴展配置,若訪問出現(xiàn)沒有配置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管理數(shù)據(jù)庫了。重新回到配置文件,找到如下代碼:
$cfg['Servers'][$i]['auth_type'] = 'config'
將上述代碼的config改為cookie,或者http,就會出現(xiàn)驗證界面了(cookie和http對應(yīng)的驗證界面在windows上還不一樣),我把它改成了cookie,出現(xiàn)如圖驗證界面。

2、這種方式也是修改phpmyadmin的配置文件,不過路徑不一樣了,在phpmyadmin/libraries找到config.default.php文件,里面包含了服務(wù)器的各種配置參數(shù)。
$cfg['Servers'][$i]['port'] = '';
找到這一行代碼,我的在132行,這個是配置端口的,值為空則是默認的3306,將其值改為3307后,保存,重啟apache,同樣可以訪問phpmyadmin了
二、phpmyadmin配置文件詳解
打開在phpmyadmin/libraries找到config.default.php文件,常用參數(shù)配置如下:
$cfg['PmaAbsoluteUri'] = ''; //phpmyadmin的訪問網(wǎng)址 ,默認就行
$cfg['TranslationWarningThreshold'] = 80; //服務(wù)器端口
$cfg['Servers'][$i]['host'] = 'localhost';//mysql主機ip,如果mysql和該phpmyadmin在同一服務(wù)器,則按默認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中配置,并且優(yōu)先級高
*$cfg['Servers'][$i]['auth_type'] = 'config'; 這個是在config.inc.php的
*配置,若不修改這個值,仍然可以直接訪問phpmyadmin
*/
$cfg['DefaultLang']='zh'; //設(shè)置默認語言
對于認證方式$cfg['Servers'][$i]['auth_type'] = ‘cookie'; 的值有四個:cookie,http,HTTP,config
config方式即輸入phpmyadmin的訪問網(wǎng)址即可直接進入,無需輸入用戶名和密碼,是不安全的,不推薦使用。
當(dāng)該項設(shè)置為cookie,http或HTTP時,登錄phpmyadmin需要數(shù)據(jù)用戶名和密碼進行驗證,,具體如下:
PHP安裝模式為Apache,可以使用http和cookie;
PHP安裝模式為CGI,可以使用cookie .
另外,在cookie模式下,還可以設(shè)置$cfg['blowfish_secret'] = ”; (短語密碼) ,至于設(shè)置為什么密碼,由您自己決定,也可以不用理會。(沒測試過,這一點來自文檔說明,我覺得不用理會就行了)
相關(guān)文章
Centos實現(xiàn)服務(wù)器時間同步的教程詳解
這篇文章主要為大家詳細介紹了Centos實現(xiàn)服務(wù)器時間同步的相關(guān)教程,文中通過圖片進行了詳細的講解,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-08-08
webpack啟動服務(wù)器和處理sourcemap的操作方法
Source Map源代碼地圖就是解決此類問題最好的辦法,從它的名字就能夠看出它的作用:映射轉(zhuǎn)換后的代碼與源代碼之間的關(guān)系,這篇文章主要介紹了webpack啟動服務(wù)器和處理sourcemap的操作方法,需要的朋友可以參考下2024-03-03
Visual Studio Code(vscode) git的使用教程
這篇文章主要介紹了詳解Visual Studio Code(vscode) git的使用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-11-11
采用軟件負載均衡器實現(xiàn)web服務(wù)器集群(iis+nginx)
我用nginx實現(xiàn)網(wǎng)站負載均衡測試的例子,windows下IIS做負載實測2016-04-04
如何在項目服務(wù)器部署git 并實現(xiàn)自動提交
這篇文章主要介紹了如何在項目服務(wù)器部署git 并實現(xiàn)自動提交,下面通過場景分析給大家介紹的非常詳細,需要的朋友參考下吧2024-07-07

