我有这个代码连接到rds实例:
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"
但我有这个错误:
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)")
你知道为什么我有这个错误吗?
答案 0 :(得分:2)
你应该检查两点: