php - 我无法通过本地 phpmyadmin 访问远程 mysql 服务器

标签 php mysql linux apache phpmyadmin

我正在尝试通过我的本地 phpmyadmin 设置(从 xampp 安装)访问我的远程 mysql 服务器。这是我的 phpmyadmin 的 config.inc.php 文件:

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'remote-mysql-server-username';
$cfg['Servers'][$i]['password'] = 'remote-mysql-server-pass';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true; 

// remote mysql server
$cfg['Servers'][$i]['verbose']       = 'remote mysql server';
$cfg['Servers'][$i]['host']          = 'some_website.com/';
$cfg['Servers'][$i]['port']          = '3306'; 
$cfg['Servers'][$i]['connect_type']  = 'tcp';
$cfg['Servers'][$i]['compress']      = FALSE;

我收到这个错误:

hpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

最佳答案

您要连接的远程 mysql 服务器必须配置为允许或接受本地主机以外的请求。 检查防火墙是否允许端口 3306(传入和传出)。

现在我们将升级情况:

1) 首先检查 mysql 配置的 my.ini 中的“bind-address”指令,它应该是 0.0.0.0 以允许来自任何 IP 地址的连接。

2) 其次,用户应该拥有我们正在访问的数据库的所有权限。

3) 第三次让 phpmyadmin 在本地主机场景下工作,在你的 phpmyadmin 配置文件的末尾添加这个 ?>(tag):

    /* Remote Server */
$i++;
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['host'] = 'myinstance.us-1.rds.amazonaws.com';//this is example enter your address
$cfg['Servers'][$i]['verbose'] = 'Remote Server Name';
$cfg['Servers'][$i]['user'] = '**********';
$cfg['Servers'][$i]['password'] = '**********'; 

现在登录本地主机并从当前服务器中选择下拉服务器名称,phpmyadmin 将完成剩下的任务。

希望对您有所帮助。

关于php - 我无法通过本地 phpmyadmin 访问远程 mysql 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43816439/

相关文章:

php - 使用 SSL 和 AUTH 的 cURL POST 到 Laravel PHP API

PHP 替换 HTML 标签以外的字符

php - 插入、获取id、同时插入

c - 如何在Linux中读取和更改内存中的值?

linux - 在 BASH 中以特定格式列出多个文件

linux - 静态目录和文件设置755,是否可以上传执行恶意脚本?

php - 在 Valetina studio 中获取 mysql 中的当前时间戳

php - 有没有办法用 PHP 从 Google Cloud Storage 下载文件?而不仅仅是阅读它

mysql - 根据条件值更新行

mysql - 你能在 LEFT JOIN 之前在 MySQL 上应用 LIMIT 吗?