我一直在寻找正确的答案,但没有找到解决方案。我的本地主机上有 WampServer 和 phpMyAdmin。我已经在远程服务器上的 phpmyadmin 中创建了一个具有所有权限的用户。
- 在文件夹 wamp/apps/phpmyadmin4.1.14/中我找到了 config.inc.php 文件
并尝试使用以下代码将其连接到远程数据库:
<?php
$i++;
/* Authentication type */
$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$i++;
/* Authentication type */
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'username';
$cfg['Servers'][$i]['password'] = 'mypass';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'example.com';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
?>
因此,在 phpMyAdmin 中我现在有第二台服务器,但是当我选择它时 - 会弹出一个错误。 MySQL 错误 #2002 如下所示:
2002 - 连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机无法响应而建立的连接失败。服务器没有响应(或者本地服务器的套接字配置不正确)。
请帮助我缺少什么!
最佳答案
您的计算机和服务器之间出现通信故障。如果是权限,您不会收到死请求,您会收到权限错误。
- 确保您的域名可用(连接到该地址并以某种方式获得答案);
- 确保您的防火墙打开了正确的端口。这可能很棘手,因为您可以使用一个端口来进入服务器,并使用不同的端口来提供服务。确保您的防火墙规则正确编写,允许您的计算机使用外部端口找到正确的内部服务。
- 使用不正确的用户名和密码。当您解决此 #2002 错误时,您将收到 #1045 访问被拒绝错误。然后您就会知道您需要担心权限并授予 IP 访问权限。
- 确保您的本地 Wamp 有可供 PhpMyAdmin 建立连接的套接字。
- 确保您的远程 MySQL 允许远程连接
关于php - 将本地 phpMyAdmin 与远程服务器连接 - 错误 #2002,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28380835/