简体   繁体   English

Amazon EC2-无法远程连接到MariaDB

[英]Amazon EC2 - Can't connect remotely to MariaDB

I'm configuring my EC2 server. 我正在配置EC2服务器。 I managed to install php, laravel etc. (with a bit of suffering though). 我设法安装了php,laravel等(虽然有点痛苦)。 Now I 现在我

  • created an user on MariaDB 在MariaDB上创建了一个用户
  • granted all permissions from remote 从远程授予所有权限
  • enabled bind-address = 0.0.0.0 in my.cnf 在my.cnf中启用了绑定地址= 0.0.0.0
  • tested local login, works 经过测试的本地登录,有效
  • opened rules in the Security group for Mysql/Aurora, port 3306, TCP, all IPs, both incoming and outcoming 在“安全性”组中为Mysql / Aurora,端口3306,TCP,所有IP(传入和传出的IP)打开规则

but still can't login from remote, I get 但仍然无法从远程登录,我得到

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

What can I do? 我能做什么? I don't have any iptables of sort, everything is supposed to be plain simple... but it's not :-( 我没有任何iptables,所有内容都应该很简单...但是不是:-(

I'm trying to connect from outside the Amazon network, with this string 我正在尝试使用此字符串从Amazon网络外部进行连接

mysql -u myuser -pmypwd -h yyz.yyz.yyz.yyz -D myschema

Please notice that from the server itself I can connect using 请注意,从服务器本身,我可以使用

mysql -u myuser -p -h localhost -P 3306 -D myschema

Thank you Marco 谢谢马可

PS For reference, here are my MariaDB users PS供参考,以下是我的MariaDB用户

+---------------------------------------------+-----------+
| host                                        | user      |
+---------------------------------------------+-----------+
| %                                           | myuser    |
| 127.0.0.1                                   | root      |
| ::1                                         | root      |
| ip-yyz-yy-zz-yyz.us-west-2.compute.internal | root      |
| localhost                                   | root      |
| localhost                                   | myuser    |
+---------------------------------------------+-----------+

EC2 instances have two IP addresses, internal and external. EC2实例有两个IP地址,内部和外部。

It looks to me like your user table authorizes access from the internal IP address. 在我看来,您的用户表授权从内部IP地址进行访问。

ip-yyz-yy-zz-yyz.us-west-2.compute.internal | root 

Are you trying to connect to the internal address from outside AWS? 您是否要从AWS外部连接到内部地址? That Doesn't Work™. 那行不通™。

If you're trying to connect to the external address, you'll have to add it to your user list. 如果您尝试连接到外部地址,则必须将其添加到用户列表中。

For troubleshooting but not production, you can add a * | root 对于故障排除而非生产,可以添加* | root * | root user. * | root用户。

You can also try https://xyz.xyz.xyz.xyz:3306 from a browser. 您也可以从浏览器尝试https://xyz.xyz.xyz.xyz:3306 It won't connect, but if it times out you know there's no route to that address from your machine. 它不会连接,但是如果超时,您就会知道没有从您的计算机到该地址的路由。 If it yields some kind of gibberish, immediately, you know the MySQL port is visible. 如果产生某种胡言乱语,您立即就会知道MySQL端口是可见的。

good news and bad news. 好消息和坏消息。

  • Good news: I solved the issue! 好消息:我解决了这个问题!
  • Bad news: We all were right. 坏消息:我们都是正确的。 It was enough to open the 3306 port in the Security Group. 打开安全组中的3306端口就足够了。 The issue was that - for reasons unknown to me - I kept seing the wrong security group. 问题是-由于我未知的原因-我一直选择错误的安全组。 I logged off, logged in again and saw the right one. 我注销,再次登录并看到正确的密码。 Enabled the port 3306 there and - magic - it worked! 在那里启用了端口3306,并且-魔术-它起作用了!

Thank you to everybody who spent time in order to help mi fixing this! 感谢所有花费时间来帮助解决此问题的人!

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

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