简体   繁体   English

如何将 android 应用程序连接到 AWS EC2 实例中的 MySQL?

[英]How to connect android application to MySQL in AWS EC2 instance?

I have written a simple android application to scan the QR code and this QR code consists of the hash value(8 digit number).我写了一个简单的 android 应用程序来扫描二维码,这个二维码由 hash 值(8 位数字)组成。

I need to connect to MySQL in EC2 to retrieve the row having the primary key of the hash value.我需要连接到 EC2 中的 MySQL 以检索具有 hash 值的主键的行。 Can anyone please suggest me any of the methods to follow to accomplish this?任何人都可以请建议我遵循的任何方法来完成此任务吗?

Thanks in advance.提前致谢。

The "quick and dirty" approach is to give your EC2 a public IP, then expose your MySql by adding a rule on a security group to allow ingress from the IP of the caller (or any IP) on port 3306. I am not sure but I think that you also have to adjust MySql configuration to allow connection from other IP than localhost. “快速而肮脏”的方法是为您的 EC2 提供一个公共 IP,然后通过在安全组上添加一条规则以允许从 IP0 的端口 3 上的 IP 进入,从而公开您的 MySql。但我认为您还必须调整 MySql 配置以允许来自其他 IP 的连接而不是本地主机。

The cleanest way would be to build a set of API, with the programming language you are more confident and expose some GET method by means of REST services.最干净的方法是构建一组 API,使用您更有信心的编程语言并通过 REST 服务公开一些 GET 方法。

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

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