简体   繁体   English

无法连接到在EC2实例(非RDS)上运行的远程MySQL实例

[英]Can't Connect to MySQL instance Remotely that is running on EC2 Instance (Not RDS)

I have seen a lot of posts that claim they are running an RDS instance of MySql in which they cannot connect to, but I am not running RDS. 我看过很多帖子声称他们正在运行他们无法连接的MySql的RDS实例,但我没有运行RDS。

I used my EC2 insance to host my wordpress blog which was installed using the Web Platform Installer. 我使用我的EC2 insance来托管我使用Web平台安装程序安装的wordpress博客。

This setup the wordpress schema and data that I needed and I have been running it for a couple years. 这设置了我需要的wordpress架构和数据,我已经运行了几年。

I want to be able to access this database remotely instead of only logging into my server. 我希望能够远程访问此数据库,而不是仅登录到我的服务器。

I have checked and have the following users 我已经检查并拥有以下用户

root
wpadmin

I have also verified that the port specified in the mysql config is the standard 3306 and I have setup an Inbound Firewall rule to allow 3306 through. 我还验证了mysql配置中指定的端口是标准3306,我已经设置了入站防火墙规则以允许3306通过。

When I try to connect from MySql Workbench, I get the following error message: 当我尝试从MySql Workbench连接时,我收到以下错误消息:

在此输入图像描述

Number 3 Is particularly one that I do not know how to check, but I do know that MySql is running and that it is running on 3306. Additionally, I know I am using the correct password. 3号特别是我不知道如何检查,但我知道MySql正在运行并且它在3306上运行。另外,我知道我使用的是正确的密码。

在此输入图像描述

When I try to connect, the prompt looks like this. 当我尝试连接时,提示符如下所示。 Do I need to do something to grant Mysql user permissions or anything? 我是否需要做一些事情来授予Mysql用户权限或任何东西?

Based on your GRANT information, you have at least the problem of root user only having access privileges from localhost. 根据您的GRANT信息,您至少有root用户只具有localhost访问权限的问题。 You would need to create a root@% user (or a more specific host/IP instead of % if you have a reliable address). 您需要创建root@%用户(如果您有可靠的地址,则需要创建更具体的主机/ IP而不是% )。 That would allow external access so long as your EC2 security group also allow access on port 3306 (either globally or to a more restrictive IP address or IP range). 只要您的EC2安全组还允许在端口3306上访问(全局或更严格的IP地址或IP范围),这将允许外部访问。

Of course the security implication here is that you are opening up access to MySQL that you might not want to make more accessbile to potential attackers. 当然,这里的安全含义是您打开了对MySQL的访问权限,您可能不希望对潜在的攻击者提供更多的访问权限。 For this reason, I would recommend you access your DB via SSH tunnel, which is supported by MySQL workbench. 因此,我建议您通过SSH工作台支持的SSH隧道访问您的数据库。 This will in essence allow you to shell into the host your your access key and then access as root@localhost . 这实际上允许您将您的访问密钥存入主机,然后以root@localhost访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM