0

I am writing MySQL code using Python using MySQL Connector. Code is - enter image description here

I have implemented this locally, and it is working properly. Now I want to deploy this file on AWS server. Its not working over there. What changes should I make, so that this code work on AWS server as well.

Thank you!!

2 Answers 2

3

Depending on where you are hosting the database, the connection details would change accordingly:

  1. Hosting Database yourself on the server itself (not recomended): If your database instance lies on the same server then your code should work as it is. This is because the host will still be localhost and you have configured the credentials appropriately. In cloud enviornment this is not recomended for various reasons - if your instance goes down, the database goes down as well and more importantly you will have to manage the database which includes things like backups, mirroring, scaling etc
  2. Use Amazon Relational Database service - RDS (recomended): Depending on the type of security you want to implement, you can take any one of the routes mentioned here. Essentially you use the endpoint of the RDS instance as the host. As for authentication, you can go the normal route of configuring username and password when configuring the instance.

RDS is the recomended way to go as being a managed service, you offload a lot of heavy lifting that comes with managing a database to AWS. If you are starting out, RDs also Free Tier bundle (link)

Note: While provisioning the RDS instance or whike updating it, be sure to mark the option of "Enable Internet Access". This will make it possible for you to access the database via the internet eg outside the VPC, from your home etc

Sign up to request clarification or add additional context in comments.

1 Comment

I am using RDP for my server deployment.
1

@Mayank Raj's answer is right, although I want to add something. if you want to deploy database server on RDS or any other server make sure you allow Port 3306 (MySQL Port) in the security group of EC2 instance.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.