从远程服务器连接到MySQL在Amazon EC2 [英] Connect to mysql on Amazon EC2 from a remote server

查看:371
本文介绍了从远程服务器连接到MySQL在Amazon EC2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要连接到数据库从我的本地机器EC2,我不能这样做,并且试图everything- 我使用这个命令连接到EC2:

I want to connect to db on EC2 from my local machine, I am not able to do and have tried everything- I am using this command to connect to EC2:

mysql -uUSERNAME -hEC2_IP -pPASSWORD

生成此错误

ERROR 2003 (HY000): Can't connect to MySQL server on 'IP' (110)

我已经修改的my.cnf

I have modified my.cnf with

skip networking
bind-address            = 0.0.0.0

仍然无法连接到数据库

Still not able to connect to the database

推荐答案

有可能是以下原因造成的:

There could be one of the following reasons:

  1. 您需要做的亚马逊安全组中的条目,以允许远程 从您的计算机访问Amazon EC2实例。 - 我相信这 是你做的,从你的问题好像你已经取得 一个条目0.0.0.0,这让所有人访问机器。
  2. 在MySQL的不允许用户从远程计算机连接 - 通过 MySQL默认创建root用户ID拥有管理员权限。但是,根 ID的访问权限仅限于本地主机。这意味着,超级用户 如果您尝试访问MySQL ID与正确的密码,将无法正常工作 从远程计算机。为了解决这个问题,你需要 让无论是root用户或其他数据库用户从远程访问MySQL 机。我不建议允许root用户ID访问数据库 从远程计算机。您可以使用通配符%指定任何远程计算机。
  3. 检查如果没有启用计算机的本地防火墙。而如果启用 然后确保3306端口是开放的。
  1. You need make an entry in the Amazon Security Group to allow remote access from your machine to Amazon EC2 instance. :- I believe this is done by you as from your question it seems like you already made an entry with 0.0.0.0, which allows everybody to access the machine.
  2. MySQL not allowing user to connect from remote machine:- By default MySql creates root user id with admin access. But root id's access is limited to localhost only. This means that root user id with correct password will not work if you try to access MySql from a remote machine. To solve this problem, you need to allow either the root user or some other DB user to access MySQL from remote machine. I would not recommend allowing root user id accessing DB from remote machine. You can use wildcard character % to specify any remote machine.
  3. Check if machine's local firewall is not enabled. And if its enabled then make sure that port 3306 is open.

请通过下面的链接:如何我是否允许远程访问MySQL数据库服务器?

这篇关于从远程服务器连接到MySQL在Amazon EC2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆