我一直在寻找一个正确的答案,并没有解决方案的运气。我的本地主机上有WampServer和phpMyAdmin。我已经在远程服务器上的phpmyadmin中创建了一个具有所有特权的用户。
并尝试使用以下代码将其连接到远程数据库:
<?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看起来像这样:
请帮助我错过了什么!
答案 0 :(得分:2)
您的机器与服务器之间的通信失败。如果是权限,则不会收到死请求,您将收到权限错误。
答案 1 :(得分:0)
您在此处列出了2个连接,因此它将显示2个连接。
因此,对于您当前的配置,列出的第二台服务器正在尝试连接到&#34; example.com &#34;服务器,如果您尝试连接到此服务器,请确保您已允许远程连接的设置,以及远程访问的帐户权限。
如果您没有尝试连接到&#34; example.com &#34;将这些行更改为您要连接的远程主机。
$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