我已经安装了最新的XAMPP和MySQL版本14.14 Distrib 5.6.21,问题出在我的电脑上,我已经有一个由我正在使用的其他程序安装的MySQL数据库。
因此,我在
my.ini
文件中将 XAMPP MySQL 端口配置为 3307(默认为 3306)。但是,现在我的 localhost/phpmyadmin 似乎读取了另一个程序安装的数据库,而不是 XAMPP 中的数据库,而且当我使用一些 PHP 文件进行测试时,它显示我已连接到数据库,即使 XAMPP 已关闭( XAMPP MySQL 也断开连接)。
如何更改 PHPMyAdmin 和 localhost 的设置以连接到 MySQL 端口 3307?
我不明白所有这些端口和数据库是如何工作的。
转到
xampp>phpMyAdmin
目录。
找到
config.inc.php
文件。
现在更改此行:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
至
$cfg['Servers'][$i]['host'] = '127.0.0.1:3307';
要配置 phpMyAdmin 连接到与默认端口不同的端口,请编辑您的
config.inc.php
文件并添加如下行:
$cfg['Servers'][$i]['port'] = '3307';
(当然可以根据需要替换任何端口号)。您还可以查看官方文档。
首先打开以下路径:
C:\xampp\phpMyAdmin
在 config.inc.php 文件中添加以下字符串。
$cfg['Servers'][$i]['port'] = '3307';
以下内容对我有用,我刚刚将端口代码添加到:
$cfg['Servers'][$i]['host'] = '127.0.0.1:3308';
在 phpMyAdmin/config.inc.php 下添加以下行
$cfg['Servers'][$i]['port'] = port number;
就我而言,端口号是
8111
。
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';
/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1:3307'; /* change port is here */
$cfg['Servers'][$i]['connect_type'] = 'tcp';