使用PHPMyAdmin管理Amazon RDS

Web*_*net 34 phpmyadmin amazon-rds

我无法让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;
Run Code Online (Sandbox Code Playgroud)

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

我收到这个错误:

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

有人有建议吗?

Rap*_*tor 34

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

sudo vi /etc/phpMyAdmin/config.inc.php # Amazon Linux
sudo vi /etc/phpmyadmin/config.inc.php # Ubuntu Linux
Run Code Online (Sandbox Code Playgroud)

找到以下行config.inc.php:

/*
 * End of servers configuration
 */
Run Code Online (Sandbox Code Playgroud)

在"服务器端配置"行上方附加以下行:

$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;
Run Code Online (Sandbox Code Playgroud)

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

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


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

$cfg['Servers'][$i]['auth_type']     = 'config';
$cfg['Servers'][$i]['user']          = '__FILL_IN_DETAILS__';
$cfg['Servers'][$i]['password']      = '__FILL_IN_DETAILS__';
Run Code Online (Sandbox Code Playgroud)

如果你的phpMyAdmin暴露给公众,这是非常危险的.您不希望向所有人显示您的数据库架构,对吗?如果您确实想使用自动登录,请确保您的phpMyAdmin仅可通过特定IP访问.


Jor*_*ona 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';
Run Code Online (Sandbox Code Playgroud)

  • 我发现指定端口导致登录错误.您也可以使用'auth_type'cookie而不指定用户和密码. (2认同)

Web*_*net 13

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

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

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

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

  • 请不要只发布链接作为答案.将答案作为文本发布,如果需要,请提供进一步说明的链接.这样,如果链接丢失,答案仍然存在. (17认同)
  • 我调整了帖子 (2认同)

小智 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
Run Code Online (Sandbox Code Playgroud)

如果这不起作用,则表示您的amazon RDS安全性未正确配置.(这是常见问题).


jet*_*com 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__';
Run Code Online (Sandbox Code Playgroud)

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

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