41

我无法让 PHPMyAdmin 连接到我的 Amazon RDS 实例。我已将我的 IP 地址的权限授予数据库安全组,该数据库可以访问我尝试访问的数据库。这就是我正在使用的...

    $cfg['Servers'][$i]['pmadb'] = $dbname;
    $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma_relation';
    $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
    $cfg['Servers'][$i]['history'] = 'pma_history';
    $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

    /* Uncomment the following to enable logging in to passwordless accounts,
     * after taking note of the associated security risks. */
    // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

    /* Advance to next server for rest of config */
    $i++;
}

    $cfg['Servers'][$i]['auth_type'] = 'http';  //is this correct?
    $cfg['Servers'][$i]['user'] = 'MASTER-USER';
    $cfg['Servers'][$i]['password'] = 'MASTER-USER-PASSWORD';
    $cfg['Servers'][$i]['hide_db'] = '(mysql|information_schema|phpmyadmin)';
    /* Server parameters */
    $cfg['Servers'][$i]['host'] = 'MY-DB.us-east-1.rds.amazonaws.com';
    $cfg['Servers'][$i]['connection_type'] = 'socket';
    $cfg['Servers'][$i]['port'] = PORT;

我不确定我的配置是否正确。

我收到此错误:

#2013 - 在“读取初始通信数据包”时丢失与 MySQL 服务器的连接,系统错误:110

有人有建议吗?

4

9 回答 9

47

我发现这个问题的大部分答案都缺乏解释。要在 EC2 中安装的 phpMyAdmin 中添加 RDS 服务器,您可以先通过 SSH 登录到您的 EC2。然后,发出以下命令来编辑 phpMyAdmin 的配置文件(使用vinano或任何其他喜欢的文本编辑工具):

sudo vi /etc/phpMyAdmin/config.inc.php # Amazon Linux
sudo vi /etc/phpmyadmin/config.inc.php # Ubuntu Linux

在 中找到以下行config.inc.php

/*
 * End of servers configuration
 */

在“服务器配置结束”行上方附加以下行:

$i++;
$cfg['Servers'][$i]['host'] = 'xxxxx.xxxxxxxxxx.us-east-1.rds.amazonaws.com';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['verbose'] = 'YOUR_SERVER_NAME';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = TRUE;

YOUR_SERVER_NAME是在 phpMyAdmin 登录页面的选择框中显示的名称。如果删除此行,整个 RDS 主机名将显示在选择框中(显然太长了)。记得保存config.inc.php.

还有其他几个配置设置,您可以在官方文档中找到详细信息。


注意:另一个答案建议使用配置文件中预设的用户名和密码自动登录:

$cfg['Servers'][$i]['auth_type']     = 'config';
$cfg['Servers'][$i]['user']          = '__FILL_IN_DETAILS__';
$cfg['Servers'][$i]['password']      = '__FILL_IN_DETAILS__';

如果您的 phpMyAdmin 公开,这是非常危险的。您不想向所有人展示您的数据库架构,是吗?如果您真的想使用自动登录,请确保您的 phpMyAdmin 只能通过特定 IP 访问。

于 2017-02-20T11:16:47.573 回答
22

在 Debian Lenny 中使用来自 repo 的 phpmyadmin 将其添加到 /etc/phpmyadmin/config.inc.php :

$i++;
$cfg['Servers'][$i]['host'] = 'xxxxx.xxxxxxxxxx.us-east-1.rds.amazonaws.com';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = TRUE;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'xxxxxxxxxxxx';
$cfg['Servers'][$i]['password'] = 'xxxxxxxxxxxxxxxxxx';
于 2011-01-12T21:19:56.020 回答
14

您需要将 RDS 实例添加为 PHPMyAdmin 上列出的附加服务器,同时授予主机 PHPMyAdmin 访问您的 RDS 实例的权限。

此博客文章中有关如何使用 PHPMyAdmin 远程管理 Amazon RDS 实例的更多详细信息:

我遇到的一件事是数据库安全组设置。当您为 CIDR/IP 添加访问权限时,它会提供推荐值。花了一些时间来确定这个默认值实际上并不是需要的。如果您在完成所有操作后仍无法连接到您的实例,请务必仔细检查此值。他们提供的 IP 与我们的 ISP 提供给我们的 IP 地址不匹配。创建数据库实例并设置安全组后,您就可以开始使用了。

我假设您已经启动并运行了 PHPMyAdmin。您需要做的是修改 config.inc.php 以识别新服务器。

于 2010-12-10T15:21:51.930 回答
10

尝试从 mysql 命令行 (http://dev.mysql.com/doc/refman/5.1/en/mysql.html) 连接,看看这个实用程序返回什么。我发现这样调试更容易。

mysql -hMY-DB.us-east-1.rds.amazonaws.com -uMASTER-USER -pPASSWORD

如果这不起作用,则意味着您的亚马逊 RDS 安全配置不正确。(这是常见问题)。

于 2010-12-15T00:25:10.957 回答
9
sudo nano /etc/phpmyadmin/config.inc.php

--ADD LINES BELOW THE PMA CONFIG AREA AND FILL IN DETAILS--
$i++;
$cfg['Servers'][$i]['host']          = '__FILL_IN_DETAILS__';
$cfg['Servers'][$i]['port']          = '3306';
$cfg['Servers'][$i]['socket']        = '';
$cfg['Servers'][$i]['connect_type']  = 'tcp';
$cfg['Servers'][$i]['extension']     = 'mysql';
$cfg['Servers'][$i]['compress']      = FALSE;
$cfg['Servers'][$i]['auth_type']     = 'config';
$cfg['Servers'][$i]['user']          = '__FILL_IN_DETAILS__';
$cfg['Servers'][$i]['password']      = '__FILL_IN_DETAILS__';

保存并退出。刷新您的 phpmyadmin 页面,您将看到刚刚添加的服务器的下拉列表在此处输入图像描述

来源:https : //github.com/andrewpuch/phpmyadmin_connect_to_rds,https://www.youtube.com/watch? v=Bz-4wTGD2_Q

于 2016-05-12T18:21:28.040 回答
1

我有同样的问题,上面没有解决它。

事实证明,事情在 RDS 实例的“公共可访问”选项中。当您创建实例时,此选项默认为“否”,您无法更改它。

但是,创建 RDS 实例后,您可以制作其快照,然后删除该实例,然后启动该快照。在启动选项中,只需将“Publicly Accessible”设置为“yes”,您的 phpMyAdmin 最终将看到您的 RDS MySql 服务器。

请注意原始 RDS 实例的 DNS 和快照不同,因此您必须更改 config.inc.php 中的“主机”

干杯:)

于 2015-07-29T00:46:28.743 回答
1

首先试试这个:

mysql -h xxxxx.xxxxxxx.xx-xx-2.rds.amazonaws.com -u root -p // 你的 RDS 服务器。

如果它等待并且不提示输入密码,那么您需要检查安全组并将 3306 出站添加到您的 Web 层。

于 2018-02-05T14:29:30.493 回答
0

如果您可以使用mysql -h ENDPOINT -u USERNAME -p但不能从 PHPMyAdmin 或您自己的 Web 脚本从 cli 进行连接,请不要忘记告诉 selinux 让您的 Web 服务器与网络通信:)

sudo setsebool -P httpd_can_network_connect=1
于 2018-04-27T14:53:51.190 回答
-1

我使用 ubuntu shell 访问 Amazon RDS。首先去ubuntu root

sudo -i

为此,请使用亚马逊 RDS 最终用户 URL

mysql -h gelastik.cqtbtepzqfhu.us-west-2.rds.amazonaws.com -u root -p
于 2015-12-11T14:05:39.980 回答