我正在尝试使用Python的pymysql库连接到RDS实例。不幸的是,我又回来了一个异常。
这是我的Python代码:
import pymysql
#Connect
connection = pymysql.connect(host='jdbc:mysql://dbname.url.us-east-1.rds.amazonaws.com/dbname',
port='3306',
user='username',
password='pass',
database='dbname')
执行它时,我收到以下异常:
Traceback (most recent call last):
File "/path/to/file/test.py", line 8, in <module>
database='treemigodb')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pymysql/connections.py", line 327, in __init__
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pymysql/connections.py", line 629, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'jdbc:mysql://dbname.url.us-east-1.rds.amazonaws.com/dbname' ([Errno 8] nodename nor servname provided, or not known)")
这是我尝试过的:
在其他示例中,我看到host
格式倾向于变化。因此,我尝试了:
jdbc:mysql://dbname.url.us-east-1.rds.amazonaws.com/dbname
jdbc:mysql://url.us-east-1.rds.amazonaws.com/dbname
jdbc:mysql://dbname.url.us-east-1.rds.amazonaws.com/
jdbc:mysql://url.us-east-1.rds.amazonaws.com/
dbname.url.us-east-1.rds.amazonaws.com/dbname
url.us-east-1.rds.amazonaws.com/dbname
dbname.url.us-east-1.rds.amazonaws.com/
是否存在一些可能会丢失的潜在设置?我已经仔细检查了所有其他参数是否匹配。