尝试执行使用 MySQL 的 Python 程序时出错
我有一个使用 MySQL 数据库的 python 程序。
我收到以下错误。
如果有人帮助我找到解决方案,我将不胜感激。
Traceback (most recent call last): File "version2_1.py", line 105, in refine(wr,w)#function for replacement File "version2_1.py", line 49, in refine wrds=db_connect.database(word) File "/home/anusha/db_connect.py", line 6, in database db = MySQLdb.connect("localhost","root","localhost","anusha" ) File "/usr/lib/pymodules/python2.6/MySQLdb/_init_.py", line 81, in Connect return Connection(*args, **kwargs) File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in __init__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
I have a python program which makes use of MySQL database.
I am getting following error.
It would be very grateful if some one help me out a solution.
Traceback (most recent call last): File "version2_1.py", line 105, in refine(wr,w)#function for replacement File "version2_1.py", line 49, in refine wrds=db_connect.database(word) File "/home/anusha/db_connect.py", line 6, in database db = MySQLdb.connect("localhost","root","localhost","anusha" ) File "/usr/lib/pymodules/python2.6/MySQLdb/_init_.py", line 81, in Connect return Connection(*args, **kwargs) File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in __init__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要阅读 MySQL 中的权限和安全性。查看这些链接:
可能是您的用户不允许完全连接,或者只允许某些类型的查询。可能是您的远程主机不允许连接到 MySQL 服务器。在为 MySQL 用户建立授权时应考虑所有这些因素。
You need to read about permissions and security within MySQL. Have a look at these links:
It could be that your user is not allowed to connect at all, or that it is only allowed certain types of queries. It could be that your remote host is not allowed to connect to the MySQL server. All of these considerations should be made when establishing grants for MySQL users.
在控制台中运行此命令
run this command in console
您的 MySQL 用户名/密码似乎不正确。尝试在 MySQL 中创建一个用户并使用它进行连接。
Looks like you have an incorrect username/password for MySQL. Try creating a user in MySQL and use that to connect.