Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connecting to mysql db on amazon rds

I am using python's MySQLdb module on a windows 7 machine and trying to connect to a remote database on Amazon RDS (SQL Server Express). Here is the simple connection scheme I am using to establish a connection, but it never works:

import MySQLdb

cnx= {'host': 'dbname.xxxxxxxxxxxx.us-west-1.rds.amazonaws.com',
  'username': 'username',
  'password': 'password',
  'db': 'dbname'}

db = MySQLdb.connect(cnx['host'],cnx['username'],cnx['password'], cnx['db'])

When i execute this connection script, it waits for a few seconds (10 to 15 secs mostly) and then gives out the following error:

OperationalError: (2003, "Can't connect to MySQL server on 'dbname.xxxx.us-west-1.rds.amazonaws.com' (10060)")

I have used sql server on localhost previously, and used to connect it using the same scheme and it worked always. Now, this is the first time I am dealing with a db on amazon rds and have no idea why this error is showing up..please help. Thanks.

like image 203
khan Avatar asked Dec 23 '13 19:12

khan


People also ask

Is Amazon RDS compatible with MySQL?

Amazon RDS supports MySQL Community Edition versions 5.7 and 8.0 which means that the code, applications, and tools you already use today can be used with Amazon RDS.

Can't connect to MySQL server on Amazon RDS?

Troubleshoot database level issuesBe sure that you're using the correct user name and password to access the instance from your DB client. Be sure that the user has the database permissions to connect to the DB instance. Check for any resource throttling in Amazon RDS, such as CPU or memory contention.

How do I connect to MySQL RDS in MySQL workbench?

Follow the steps below to connect MySQL Workbench to your Amazon RDS DB instance: Download and install MySQL Workbench. Open MySQL Workbench, and then choose the ⊕ sign beside MySQL Connections to set up a new connection. In the Setup New Connection dialog box, enter a name for your connection.


1 Answers

It's been 7 months and likely you have already figured out by now... That's probably because you have not added the IP of machine where you are connecting from to the security group of the RDS instance. First go to the RDS instance details page, click on the link to the security group, then you should find at the bottom of the page to add IP of your connecting host.

like image 56
Anthony Avatar answered Oct 04 '22 03:10

Anthony