(1045,“用户'root'@'ip-address'的访问被拒绝(使用密码:是)")在python中 [英] (1045, "Access denied for user 'root'@'ip-address' (using password: YES)") in python

查看:38
本文介绍了(1045,“用户'root'@'ip-address'的访问被拒绝(使用密码:是)")在python中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 pymysql(python 库)访问域 my_domain_name 上托管的 MySql 数据库.我的代码是:

I want to access MySql database hosted on domain my_domain_name using pymysql ( python library) . My code is:

connection = pymysql.connect('my_domain_name', user, passd, db)

但我收到此错误

(1045, "Access denied for user 'root'@'ip-address' (using password: YES)")

在大多数答案中,人们建议:

In most answers, people suggest that:

密码错误或root"用户没有权限访问数据库

either password is wrong or 'root' user do not have privileges to access database

但是,我可以使用直接链接访问数据库:http://www.my_domain_name/phpmyadmin/index.php 使用相同的用户和密码.我会感谢你的帮助.谢谢

But, I can access the database using direct link as: http://www.my_domain_name/phpmyadmin/index.php using same user and password. I will appreciate your kind help. Thanks

注意:'my_domain_name' 正在转换为 ip_address.当我将此 IP 放置到我的浏览器时,它会将我带到我的 Internet 提供商的网站.

Note: 'my_domain_name' is being converted to an ip_address. When I place this IP to my browser, it takes me to the website of my Internet provider.

更新:很明显,domain_name 正在被 Internet 提供商的 ip_address 替换.我该如何解决这个问题?请分享任何链接.谢谢.

Update: It is clear that domain_name is being replaced with ip_address of Internet provider. How can I resolve this issue? Please do share any link. Thanks.

推荐答案


问题是默认情况下,MySql 服务器不会为用户分配远程访问数据库所需的权限.因此,打开您的 SqlServer 控制台并使用此命令将权限分配给root"用户:


The issue was that by default, MySql server does't assign necessary privileges to the user to access database remotely. So, open your SqlServer console and use this command to assign privileges to the 'root' user as:

GRANT ALL ON root.* TO 'root'@'ip_address_of_server' IDENTIFIED BY 'password_for_root' ;
FLUSH PRIVILEGES;

 GRANT ALL ON root.* TO 'root'@'server_name' IDENTIFIED BY 'password_for_root' ;
    FLUSH PRIVILEGES;

有关更多信息,请参阅此答案:pymysql无法连接到mysql

Refer to this answer for more information: pymysql cannot connect to mysql

这篇关于(1045,“用户'root'@'ip-address'的访问被拒绝(使用密码:是)")在python中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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