无法使用Python连接到AWS EC2数据库

时间:2018-11-05 06:27:53

标签: python-3.x amazon-web-services

我是python的新手,我试图连接到我的AWS EC2 RDS数据库,但它不连接到AWS db。抛出错误

mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'xx.xxx.xx.xxx:3306' (10061 No connection could be made because the target machine actively refused it)

当我尝试连接到本地主机时,它可以很好地连接,并且说已连接到Mysql数据库。我正在使用以下代码连接到数据库。

import mysql.connector

db = mysql.connector.connect(host='xx.xxx.xx.xxx', database='bm_new', user='dbusername', password='dbpassword')
if db.is_connected():
    print('connected to Mysql database') 

我修改了mysql.cnf,将绑定地址更改为0.0.0.0,甚至将其更改为服务器IP,但问题仍然存在。任何建议将不胜感激。

0 个答案:

没有答案
相关问题