我希望标题是不言自明的。我使用 Amazon RDS 和 EC2 实例在同一台机器上设置了数据库和网络服务器。我在机器的cgi文件夹中运行 Python 脚本,但无法连接到数据库。错误的顺序是:_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)")我已经尝试过mySQLdb,_mysql但没有成功。我不明白的是,我能够通过命令行成功连接到 mysql 客户端,mysql -u username -p -h edutechfinal.cqk0lckbky4e.us-east-2.rds.amazonaws.com但不在脚本内。这是我在 Python 脚本中尝试过的db = _mysql.connect("127.0.0.1","st4rgut25","pwd","st4rgut25")和db = MySQLdb.connect(host="127.0.0.1",user="st4rgut25",passwd="pwd",db="st4rgut25")
添加回答
举报
0/150
提交
取消