通过XAMPP访问phpmyadmin管理mysql数据库

XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建 XAMPP 软件站集成软件包,轻巧,用起来很方便。它提供了强大的phpmyadmin数据库管理工具,让使用者对数据库的使用和管理得心应手。对于不能在本地打开phpmyadmin的问题,我的解决方案如下:

MySQL有一个默认的专用端口:3306,所以,如果你之前独立安装了MySQL,那么3306端口已经被占用。安装XAMPP集成的MySQL时,必须重新设置独立的端口,否则是不能访问phpmyadmin的。

修改方法也很方便,打开XAMPP的控制面板,找到mysql右侧的config,点击,会出现my.ini的选择项,这个就是mysql的配置文件了。也可以在XAMPP的安装路径下找:xamppmysqlinmy.ini

如图中所示,将端口port改成3307;当然只是修改端口,还是访问不了,还要去修改phpmyadmin的配置文件。

打开xampp目录(找到xampp的安装目录),打开phpmyadmin的目录,在该目录下找到config.inc.php,即:xamppphpmyadminconfig.inc.php。

[php] view plain copy
 
  1. <?php  
  2. /* 
  3.  * This is needed for cookie based authentication to encrypt password in 
  4.  * cookie 
  5.  */  
  6. $cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */  
  7.   
  8. /* 
  9.  * Servers configuration 
  10.  */  
  11. $i = 0;  
  12.   
  13. /* 
  14.  * First server 
  15.  */  
  16. $i++;  
  17.   
  18. /* Authentication type and info */  
  19. $cfg['Servers'][$i]['auth_type'] = 'config';  
  20. $cfg['Servers'][$i]['user'] = 'username';            //mysql用户名  
  21. $cfg['Servers'][$i]['password'] = 'password';       //mysql密码  
  22. $cfg['Servers'][$i]['extension'] = 'mysqli';     //扩展配置,若访问出现没有配置mysqli等错误,加上这个。默认是有的  
  23. $cfg['Servers'][$i]['AllowNoPassword'] = true;  
  24. $cfg['Lang'] = '';  
  25.   
  26. /* Bind to the localhost ipv4 address and tcp */  
  27. $cfg['Servers'][$i]['host'] = '127.0.0.1';  
  28. $cfg['Servers'][$i]['connect_type'] = 'tcp';  
  29.   
  30. /* User for advanced features */  
  31. $cfg['Servers'][$i]['controluser'] = 'pma';  
  32. $cfg['Servers'][$i]['controlpass'] = '';  
  33.   
  34. /* Advanced phpMyAdmin features */  
  35. $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';  
  36. $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';  
  37. $cfg['Servers'][$i]['relation'] = 'pma_relation';  
  38. $cfg['Servers'][$i]['table_info'] = 'pma_table_info';  
  39. $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';  
  40. $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';  
  41. $cfg['Servers'][$i]['column_info'] = 'pma_column_info';  
  42. $cfg['Servers'][$i]['history'] = 'pma_history';  
  43. $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';  
  44. $cfg['Servers'][$i]['tracking'] = 'pma_tracking';  
  45. $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';  
  46. $cfg['Servers'][$i]['recent'] = 'pma_recent';  
  47. $cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';  
  48.   
  49. /* 
  50.  * End of servers configuration 
  51.  */  
  52.   
  53. ?>  

然后在$cfg['Lang'] ="   "; 后加入以下代码即可:

[php] view plain copy
 
  1. $cfg['Servers'][$i]['port'] = '3307'  


保存文件,重启apache,确保mysql打开,在地址栏输入localhost/phpmyadmin,就可以直接进入phpmyadmin的管理界面了,如图所示:

原文地址:https://www.cnblogs.com/zzc666/p/7718889.html