通过Python MySqlDb连接到MySQL(1045错误)
我在 OSX Lion 上使用 Python 2.7,无法连接到 Python 上的远程 SQL Db。我收到以下错误:
Traceback (most recent call last):
File "connectDB.py", line 39, in <module>
main()
File "connectDB.py", line 16, in main
db = MySQLdb.connect(HOST, USER, PASSWORD, DBNAME )
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 81, in Connect
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/connections.py", line 187, in __init__
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'ekogan'@'dyn-209-2-217-168.dyn.columbia.edu' (using password: YES)")
我知道我的主机和用户/通行证有效,因为我可以通过 PHP 访问它。但由于某种原因,这里被否认了。是否存在一些 SQL 版本控制问题?我完全不确定如何继续。
I am using Python 2.7 on OSX Lion and can't connect to a remote SQL Db on Python. I get the following error:
Traceback (most recent call last):
File "connectDB.py", line 39, in <module>
main()
File "connectDB.py", line 16, in main
db = MySQLdb.connect(HOST, USER, PASSWORD, DBNAME )
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 81, in Connect
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/connections.py", line 187, in __init__
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'ekogan'@'dyn-209-2-217-168.dyn.columbia.edu' (using password: YES)")
I know my host and user/pass work because I'm able to access it via PHP. But for some reason it's denied here. Could there be some SQL versioning issues? I am totally unsure of how to proceed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PHP 可能不会作为远程主机访问您的 MySQL 服务器。 Python 可能会这样做。所以检查你的权限。
PHP probably does not access your MySQL server as a remote host. Python probably does. So check your permissions.
如果您有权检查
mysql.user
表,请打开终端并输入上面的内容,将
PASSWORD
更改为用引号括起来的密码值(即,如果您的密码是foobar
,将PASSWORD
更改为"foobar"
)。用户、主机和密码必须与
mysql.user
表中的条目匹配。If you have permission to inspect the
mysql.user
table, open a terminal and typeAbove, change
PASSWORD
to the value of your password surrounded by quotes, (i.e. if your password isfoobar
, changePASSWORD
to"foobar"
).The user, host and password must match an entry in the
mysql.user
table.