我无法让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
有人有任何建议吗?
答案 0 :(得分:31)
我发现这个问题的大部分答案都没有解释。要在EC2中安装的phpMyAdmin中添加RDS服务器,您可以先通过SSH登录EC2。然后,发出以下命令来编辑phpMyAdmin的Config文件(使用vi
,nano
或任何其他喜欢的文本编辑工具):
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
。
还有其他一些配置设置,您可以在official documentation中找到详细信息。
注意:另一个答案建议使用预设用户名和自动登录进行自动登录密码在Config文件中:
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = '__FILL_IN_DETAILS__';
$cfg['Servers'][$i]['password'] = '__FILL_IN_DETAILS__';
如果您的phpMyAdmin公开,则非常危险。您不希望向所有人显示您的数据库架构,对吗?如果您确实想使用自动登录,请确保您的phpMyAdmin仅可通过特定IP访问。
答案 1 :(得分: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';
答案 2 :(得分:13)
您需要将RDS实例添加为PHPMyAdmin上列出的其他服务器,同时授予主机PHPMyAdmin访问您的RDS实例的权限。
此How to remotely manage an Amazon RDS instance with PHPMyAdmin上的博文中的更多详情:
我遇到的一件事就是数据库安全组的设置。当您为CIDR / IP添加访问权限时,它会提供建议值。花了一些时间来确定这个默认值实际上并不是那里需要的东西。如果在完成所有操作后无法连接到您的实例,请务必仔细检查此值。他们提供的IP与我们的ISP提供给我们的IP地址不符。一旦您创建了数据库实例并设置了安全组,就可以了。
我假设您已经启动并运行了PHPMyAdmin。您需要做的是修改config.inc.php以识别新服务器。
答案 3 :(得分:9)
尝试从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安全性配置不正确。 (这是常见的问题)。
答案 4 :(得分:7)
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
答案 5 :(得分:0)
I had the same problem and nothing of the above solved it.
As it turned out the thing was in "Publicly Accessible" option of the RDS instance. When you create your instance this option is "no" by default and there is no place you can change it.
However, after creating the RDS instance you can make its snapshot, then delete the instance and then launch the snapshot. In launch options just set "Publicly Accessible" to "yes" and your phpMyAdmin will finally see you RDS MySql server.
Beware that DNS of the original RDS instance and the snaphot are different so you would have to change your 'host' in config.inc.php
Cheers :)
答案 6 :(得分:0)
首先尝试这个:
mysql -h xxxxx.xxxxxxx.xx-xx-2.rds.amazonaws.com -u root -p //您的RDS服务器。
如果它等待并且没有提示输入密码,那么您需要检查安全组并将3306出站添加到您的Web层。
答案 7 :(得分:0)
如果您可以使用mysql -h ENDPOINT -u USERNAME -p
而不是PHPMyAdmin或您自己的网络脚本从cli连接,请不要忘记tell selinux to let your web server talk to the network:)
sudo setsebool -P httpd_can_network_connect=1
答案 8 :(得分:-1)
我使用ubuntu shell访问Amazon RDS。 首先去ubuntu root
sudo -i
使用amazon RDS最终用户URL
mysql -h gelastik.cqtbtepzqfhu.us-west-2.rds.amazonaws.com -u root -p