简体   繁体   English

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

[英]Connect local phpMyAdmin with remote server - error #2002

I have been searching for a right answer and no luck with solutions. 我一直在寻找正确的答案,没有运气好的解决方案。 I have WampServer and phpMyAdmin on my localhost. 我的本地主机上有WampServer和phpMyAdmin。 I have created a user in phpmyadmin on remote server with all privilages. 我已经在具有所有特权的远程服务器上的phpmyadmin中创建了一个用户。

  • in folder wamp/apps/phpmyadmin4.1.14/ I have found config.inc.php file 在文件夹wamp / apps / phpmyadmin4.1.14 /中,我找到了config.inc.php文件

And tried to connect it to the remote databases with the following code: 并尝试使用以下代码将其连接到远程数据库:

<?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;
?>

And, as a result, in phpMyAdmin now I have 2nd server, but when I choose it - an error pops-up. 结果,现在在phpMyAdmin中,我有第二台服务器,但是当我选择它时-会弹出一个错误。 MySQL error #2002 that looks like this: MySQL错误#2002看起来像这样:

2002 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 2002-连接尝试失败,因为一段时间后连接方未正确响应,或者连接建立失败,因为连接的主机未能响应。 The server is not responding (or the local server's socket is not correctly configured). 服务器没有响应(或未正确配置本地服务器的套接字)。

Please help what am I missing! 请帮助我所缺少的!

You are suffering from a failure of communication between your machine and the server. 您的机器与服务器之间的通信失败。 If it was permission, you wouldn't get a dead request, you would get the permission error. 如果是权限,则不会收到无效请求,而会出现权限错误。

  • Make sure your domain is available (connect to the address and get an answer somehow); 确保您的域可用(连接到该地址并以某种方式获得答案);
  • Make sure your firewall has the proper port open. 确保您的防火墙打开了正确的端口。 This can be tricky since you can use one port for entering the server and a different port for the service. 这可能很棘手,因为您可以使用一个端口进入服务器,而使用另一个端口来服务。 Make sure your firewall rule is correctly written in a way that it allows your machine to use an external port to find the right internal service. 确保正确编写了防火墙规则,该规则允许您的计算机使用外部端口找到正确的内部服务。
  • Use INCORRECT username and password. 使用不正确的用户名和密码。 When you solve this #2002 error, you will get a #1045 access denied error. 解决此#2002错误时,您将收到#1045访问被拒绝错误。 Then you'll know that you need to be worrying about permission and grant IP access. 然后,您将知道需要担心权限和授予IP访问权限。
  • Make sure your local Wamp has sockets available for PhpMyAdmin to establish the connection. 确保您的本地Wamp具有可供PhpMyAdmin使用的套接字以建立连接。
  • Make sure your remote MySQL allows remote connections 确保您的远程MySQL允许远程连接

You have 2 connections listed there so it will show 2 connections. 您在那里列出了2个连接,因此它将显示2个连接。

So for your current config the 2nd server listed is trying to connect to " example.com " server if you are trying to connect to this server make sure you have allowed remote connection's set up, and account privileges also for remote access. 因此,对于您当前的配置,如果您尝试连接到“ example.com ”服务器,则列出的第二台服务器将尝试连接到该服务器,请确保您已允许设置远程连接,并且还具有用于远程访问的帐户特权。

If your not trying to connect to " example.com " change these lines to the remote host you want to connect to. 如果您不尝试连接到“ example.com ”,请将这些行更改为要连接的远程主机。

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

You may need to add in port as well 您可能还需要添加端口

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM