【发布时间】:2014-05-19 11:35:10
【问题描述】:
f_db我正在尝试使用 python 脚本连接到 mysql 数据库。我这样做的代码如下:
`db = MySQLdb.connect(host="xxx.xx.xx.xx", # your host, usually localhost
port = xxxx,
user="chrathan", # your username
passwd="...", # your password
db="f_db") # name of the data base`
我已经从 mysql 工作台打开数据库。但是,我无法从 python 打开它,我收到以下错误:
_mysql_exceptions.OperationalError: (1044, "Access denied for user 'chrathan'@'%' to database 'f_db'"). Basically I am receiving `Traceback (most recent call last):
File "D:\_WORKSPACE\mysql\fashion_db.py", line 7, in <module>
db = 'f_db') mysql_exceptions.OperationalError: (1044, "Access denied for user 'chrathan'@'%' to database 'f_db'")`
【问题讨论】:
-
我发现错误代表数据库名称。当我删除该行时,它起作用了!因此问题在于最后一行和数据库的名称。
-
我在工作台上连接了该信息。为什么现在我的用户'chrathan'@'%'拒绝访问数据库'f_db'
-
请编辑您的问题并添加您在 cmets 中提供的信息。评论不适用于这种用法!