将本地phpMyAdmin与远程服务器连接-错误#2002


Connect local phpMyAdmin with remote server - error #2002

我一直在寻找正确的答案,但没有找到解决方案。我的本地主机上有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允许远程连接

这里列出了2个连接,因此它将显示2个连接。

因此,对于您当前的配置,列出的第二台服务器正在尝试连接到"example.com"服务器。如果您正在尝试连接到此服务器,请确保您已允许设置远程连接,并具有远程访问的帐户权限。

如果您没有尝试连接到"example.com",请将这些线路更改为要连接的远程主机。

$cfg['Servers'][$i]['user'] = 'username';
$cfg['Servers'][$i]['password'] = 'mypass';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'example.com';

您可能需要添加端口以及

$cfg['Servers'][$i]['port'] = '3307'; // MySQL port