SQLException:null, message from server: “Host ‘xx‘ is not allowed to connect to this MySQL server“

java.sql.SQLException: null,  message from server: "Host 'PC-20220124VASY' is not allowed to connect to this MySQL server"

以上报错信息为,当前登录的mysql账号没有访问权。只能使用'localhost'或'127.0.0.1'访问,使用本地电脑的IP地址也是不可以访问的。

解决思路:

修改当前登录的mysql账号的访问权限

#登录mysql

mysql -u账号 -p密码

#登录成功之后进入mysql数据库

use mysql

#查询user表

select user,host from user;

 #修改当前root账号的访问权限

update user set host='%' where user='root';

#刷新

flush privileges;

 #再次查询

select user,host from user;

经过以上的操作,再次启动项目这个问题就解决了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
java.sql.SQLException: null, message from server: "Host '59.41.160.220' is not allowed to connect to this MySQL server"是一个错误消息,表示指定的主机(59.41.160.220)没有权限连接到MySQL服务器。这通常是由于MySQL服务器的访问控制列表(ACL)配置导致的。 要解决这个问题,可以采取以下步骤: 1. 登录到MySQL服务器。 2. 运行以下命令以授予指定主机的访问权限: GRANT ALL PRIVILEGES ON *.* TO 'username'@'59.41.160.220' IDENTIFIED BY 'password'; 其中,'username'是您希望使用的用户名,'59.41.160.220'是您希望授予访问权限的主机IP地址,'password'是您希望使用的密码。 3. 刷新MySQL权限以使更改生效: FLUSH PRIVILEGES; 4. 退出MySQL服务器。 通过执行上述步骤,您应该能够解决java.sql.SQLException: null, message from server: "Host '59.41.160.220' is not allowed to connect to this MySQL server"错误,并允许指定主机连接到MySQL服务器。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [bug-linux-win(java.sql.SQLException: null, message from server: “Host ‘192.168.1.66‘ is not ...](https://blog.csdn.net/computer408/article/details/123920935)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [java.sql.SQLException: null, message from server: “Host ‘%’ is not allowed to connect to](https://download.csdn.net/download/weixin_38720653/13687787)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

C吴新科

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值