栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java.sql.SQLException: null, message from server: “Host ‘x.xxx.xxx.xxx‘ is not allowed to connect

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java.sql.SQLException: null, message from server: “Host ‘x.xxx.xxx.xxx‘ is not allowed to connect

DruidDataSource : create connection error, url: jdbc:mysql://x.xxx.xxx.xxx:3306/miaosha, errorCode 1130, state HY000

java.sql.SQLException: null,  message from server: "Host 'x.xxx.xxx.xxx' is not allowed to connect to this MariaDB server"
 

当我们在本地做完一些项目(需要访问mysql数据库),并且想布置到云服务器上,于是把项目打包上传,并且将本地数据库数据备份下来也上传到云服务器上后,尝试在云服务器上启动该项目,却发现了如下异常:

其实这个异常是数据库只允许 localhost 或 127.0.0.1 访问,不允许远程访问。

解决方案:修改访问权限即可

具体操作步骤如下:

首先进入数据库:

mysql -uroot -proot

 进入mysql

use mysql;

查看权限 

select host,user from user;

我们发现 root 对应的 host 是 localhost,表示只允许本机访问,我们需要把他改为 %

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

 最后刷新一下权限

flush privileges;

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/913937.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号