Mysql OperationalError 1044,连接到mysql数据库 [英] Mysql OperationalError 1044, connect to mysql database

查看:88
本文介绍了Mysql OperationalError 1044,连接到mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

f_db我正在尝试使用python脚本连接到mysql数据库.我的代码如下:

f_dbI am trying to connect to mysql database using a python script. My code to do so is the following:

 `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打开它,出现以下错误:

I ve open the database from mysql workbench. However, I am not able to open it from python I am getting the following error:

_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'")` 

推荐答案

在mysql终端上输入此命令

enter this command on mysql terminal

$> mysql
GRANT ALL PRIVILEGES ON f_db.* TO 'chrathan'@'%' identified by 'secret'

要将用户添加到mysqlworkbench中的数据库,请参见此页面

for add user to database in mysqlworkbench look at this page How to Create a MySQL Database with MySQL Workbench

这篇关于Mysql OperationalError 1044,连接到mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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