无法通过瓶SQLAlchem​​y的URI从Python的弹性魔豆连接到AWS MySQL的RDS实例 [英] Unable to connect to AWS MySQL RDS instance via Flask SQLAlchemy URI from Python Elastic Beanstalk

查看:364
本文介绍了无法通过瓶SQLAlchem​​y的URI从Python的弹性魔豆连接到AWS MySQL的RDS实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了在那里我无法从我的瓶的应用程序连接到我的RDS MySQL实例的问题。我使用SQLAlchem​​y的,一切都在本地工作,但是当我把我的code到AWS我得到以下错误:

I am running into an issue where I am unable to connect to my RDS MySQL instance from my Flask app. I am using SQLAlchemy and everything is working locally but when I push my code to AWS I get the following error:

sqlalchemy.exc.OperationalError

OperationalError: (OperationalError) (1045, "Access denied for user 'db_user'@'xx.xx.xx.xxx' (using password: YES)") None None

现在我知道一个事实,即错误不是一个安全组的问题,因为我能够连接本地和使用MySQL客户端的实例。

Now I know for a fact that the error is not a security group issue as I am able to connect locally and on the instance using the MySQL client.

推荐答案

那么事实证明我并没有做错什么,这是不符合AWS或瓶的错误,这是严格意义上的SQLAlchem​​y的错误!原来,URI格式的MySQL连接是:

Well it turns out I wasn't doing anything wrong and this wasn't an error with AWS or Flask, it was strictly a SQLAlchemy bug! It turns out the URI format for MySQL connections is:

dialect+driver://username:password@host:port/database

我的错误来自于一个事实,即我有一个加号(+)字符从而愚弄URI格式,以为一切之前,它是方言密码。使用+字符是完全合法的MySQL的密码,因此,为什么通过MySQL客户端连接进行工作。我希望其他人有此错误是能够找到这一点,并没有花费太多的时间,因为我也想找到一个解决办法!

My bug came from the fact that my password with a plus (+) character in it thus fooling the URI format into thinking everything before it was the dialect. Using a '+' character is completely legal for MySQL passwords and thus why connecting via the MySQL client was working. I hope anyone else with this error is able to find this and not spend as much time as I did trying to find a solution!

这篇关于无法通过瓶SQLAlchem​​y的URI从Python的弹性魔豆连接到AWS MySQL的RDS实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆