I have this code to connect to a rds instance:
import MySQLdb
USERNAME = 'root'
PASSWORD = 'pass'
DB_NAME = 'databasetest2'
print "Connecting to RDS instance"
conn = MySQLdb.connect ( host = 'mysql-db-instance-database-test2.code.us-east-1.rds.amazonaws.com', user = USERNAME, passwd = PASSWORD, db = DB_NAME, port = 3306)
print "Connected to RDS instance"
But Im having this error:
Connecting to RDS instance
Traceback (most recent call last):
File "mysql.py", line 10, in <module>
conn = MySQLdb.connect ( host = 'mysql-db-instance-database-test2.code.us-east-1.rds.amazonaws.com', user = USERNAME, passwd = PASSWORD, db = DB_NAME, port = 3306)
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'mysql-db-instance-database-test2.code.us-east-1.rds.amazonaws.com' (110)")
Do you see why Im having this error?
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.
Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/ . In the navigation pane, choose Databases to display a list of your DB instances. Choose the name of the MySQL DB instance to display its details. On the Connectivity & security tab, copy the endpoint.
When you can't connect to a DB instance, the following are common causes: Inbound rules – The access rules enforced by your local firewall and the IP addresses authorized to access your DB instance might not match. The problem is most likely the inbound rules in your security group.
YOu should check two points:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With