简体   繁体   English

如何将弹性benstalk上部署的Web应用程序与AWS上的mysql数据库实例连接?

[英]how to connect web application deployed on elastic benstalk with mysql database instance on aws?

I have a web application deployed on elastic beanstalk. 我在弹性beantalk上部署了一个Web应用程序。 I have configured MySQL database for it. 我已经为其配置了MySQL数据库。 In database instance in security group i have done following changes: Type(MYSQL/Aurora), protocol(TCP), port range(3306) and source(0.0.0.0/0). 在安全组的数据库实例中,我进行了以下更改:类型(MYSQL / Aurora),协议(TCP),端口范围(3306)和源(0.0.0.0/0)。 when i am trying to insert data into database using web application or fetch data from database using web application which is deployed on elastic beanstalk, i am not able to do it. 当我尝试使用Web应用程序将数据插入数据库或使用部署在弹性beantalk上的Web应用程序从数据库中获取数据时,我无法做到。 I have made changes in servlet code as mentioned on aws website but connection is not establishing between web application and RDS on aws. 我已经对aws网站上提到的servlet代码进行了更改,但是在aws上的Web应用程序和RDS之间没有建立连接。 I don't know where i am doing the mistake. 我不知道我在哪里做错。 please help me to achieve it. 请帮助我实现它。

Please follow the below steps to connect the mysql instance from web application: 请按照以下步骤从Web应用程序连接mysql实例:

  • Copy the Endpoint from the RDS instance which will be the hostname for your mysql database. 从RDS实例复制端点,它将是您的mysql数据库的主机名。
  • SSH into the EC2-Instance SSH进入EC2-Instance
  • Use mysql to connect to the RDS instance using the following command: 使用mysql通过以下命令连接到RDS实例:

    mysql -u username -p -h HOSTNAME mysql -u用户名-p -h主机名


where HOSTNAME is the endpoint of your RDS instance. 其中HOSTNAME是您的RDS实例的端点。

Also, you have mentioned you have inbound all the traffic in the VPC security groups. 另外,您提到您已经入站了VPC安全组中的所有流量。 This is not the recommended way to connect to a database.Database should always be secured from the outside world. 这不是推荐的连接数据库的方法。数据库应始终与外界隔离。 You have to explicitly mention the source from where the connections will be coming. 您必须明确提及连接的来源。
Eg: 例如:
Type Protocol Port Range Source 类型协议端口范围源
MySQL/Aurora TCP 3306 security group id of the application 应用程序的MySQL / Aurora TCP 3306安全组ID

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

相关问题 如何在AWS Elastic Beanstalk部署的Java Web应用程序中启用WebSocket请求 - How to Enable WebSocket request in AWS Elastic Beanstalk deployed Java web application 如何将 AWS MYSQL 实例连接到 android 应用程序(Java) - How to connect AWS MYSQL instance to android application (Java) 如何从AWS Elastic Beanstalk连接到Google Cloud SQL实例 - How to connect to a google cloud sql instance from AWS elastic beanstalk Java Web 应用程序无法连接到 AWS RDS 数据库实例 - Java web application cannot connect to AWS RDS DB Instance 如何从Spring Java Elastic Beanstalk应用程序连接到我的AWS DynamoDB实例? - How do I connect to my AWS DynamoDB instance from a Spring Java Elastic Beanstalk app? 如何将Android应用程序连接到MySQL数据库? - How to connect an Android application to a MySQL database? 如何为AWS EC2实例中部署的Spring Boot Rest API Web服务创建IAM角色 - how to create IAM role for a spring boot rest api web service deployed in aws ec2 instance 使用Java Web Start部署的应用程序进行数据库迁移 - Database Migration with a Java Web Start deployed Application AWS Elastic Beanstalk(单实例):如何为 Spring 启动应用程序启用 HTTPS? - AWS Elastic Beanstalk (single instance) : how to enable HTTPS for a Spring Boot application? 无法将我的 java 应用程序连接到 Elastic Stack 实例 - Unable to connect my java application to the Elastic Stack Instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM