XAMPP(Apache+MySQL+PHP+PERL)是一個功能強大的建 XAMPP 軟件站集成軟件包,輕巧,用起來很方便。它提供了強大的phpmyadmin數據庫管理工具,讓使用者對數據庫的使用和管理得心應手。對於不能在本地打開phpmyadmin的問題,我的解決方案如下:
MySQL有一個默認的專用端口:3306,所以,如果你之前獨立安裝了MySQL,那么3306端口已經被占用。安裝XAMPP集成的MySQL時,必須重新設置獨立的端口,否則是不能訪問phpmyadmin的。
修改方法也很方便,打開XAMPP的控制面板,找到mysql右側的config,點擊,會出現my.ini的選擇項,這個就是mysql的配置文件了。也可以在XAMPP的安裝路徑下找:\xampp\mysql\bin\my.ini
如圖中所示,將端口port改成3307;當然只是修改端口,還是訪問不了,還要去修改phpmyadmin的配置文件。
打開xampp目錄(找到xampp的安裝目錄),打開phpmyadmin的目錄,在該目錄下找到config.inc.php,即:\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,確保mysql打開,在地址欄輸入localhost/phpmyadmin,就可以直接進入phpmyadmin的管理界面了,如圖所示: