java.sql.SQLException: null, message from server: Host 'XXXXX' is not allowed to connect
本人问题出现在,在linux的spark shell上,使用JDBC从其他数据库读取数据时,已导入mysql-connector-java-5.1.47-bin.jar包,运行代码时报错。
//以下xxx.xxx.xx.x为本机ip,saprksqltest为mysql的数据库名,data为数据库中表名
val jdbcDF = spark.read.format("jdbc").option("url","jdbc:mysql://xxx.xxx.xx.x:3306/sparksqltest").option("dbtable", "data").option("user", "root").option("password","000000").load()
报错信息:
java.sql.SQLException: null, message from server: "Host 'xxx-xxx' is not allowed to connect to this MySQL server"at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1038)...
查询确认为数据库服务器不允许远程连接,解决方法为:
如果安装有mysql的可视化界面:
1). 打开可视化界面并登陆
2). 找到mysql数据库,找到并打开其中的user表,修改host的值从localhost改为%(localhost表示只支持本地连接,不支持外网连接)
3). 执行代码刷新权限flush privileges;如果未安装mysql的可视化界面
1). 找到本地安装mysql的位置
2). 在bin目录下执行:mysql -u root -p 密码 登陆到mysql数据库
3). 执行代码use mysql,使用mysql数据库
4). 执行代码update user set host=’%’ where user =‘root’;
5). 执行代码刷新权限flush privileges;
以上执行完毕,即可用外网进行mysql连接测试
继续执行代码
//以下xxx.xxx.xx.x为本机ip,saprksqltest为mysql的数据库名,data为数据库中表名
val jdbcDF = spark.read.format("jdbc").option("url","jdbc:mysql://xxx.xxx.xx.x:3306/sparksqltest").option("dbtable", "data").option("user", "root").option("password","000000").load()
显示连接成功
jdbcDF: org.apache.spark.sql.DataFrame = [id: int, name: string]
java.sql.SQLException: null, message from server: Host 'XXXXX' is not allowed to connect相关推荐
- java.sql.SQLException: null, message from server: “Host ‘XXX‘ is not allowed to connect异常(22.11.26)
项目场景: 瑞吉外码项目优化部分,项目实现读写分离,配置两个数据源 问题描述 报错java.sql.SQLException: null, message from server: "Hos ...
- java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect异常解决
表示不能被允许远程访问,ip地址必须是localhost或者127.0.0.1,就算是局域网内也不行. 出现此异常的原因一般是在迁移项目后,只要你项目的数据库配置文件下的ip不是localhost或者 ...
- Caused by: java.sql.SQLException: null, message from server: “Host ‘allen‘ is not allowed to connec
启动metastore的报错 Caused by: java.sql.SQLException: null, message from server: "Host 'allen' is no ...
- mysql_java.sql.SQLException: null, message from server: Host 'xxx' is not allowed to connect
在连接远程服务器上的数据库的时候,出现mysql_java.sql.SQLException: null, message from server: "Host 'xxx' is not a ...
- java.sql.SQLException : null, message from server: “Host ‘‘ is not allowed to connect to this Maria
文章目录 错误详情 错误原因 解决方案 最后 错误详情 今天在初始化云主机中Hive时报错如下: Underlying cause: java.sql.SQLException : null, mes ...
- Hive连接Spark报错java.sql.SQLException: null, message from server: Host 'datanode03' is blocked becaus
背景: 线上一些任务大部分使用Spark Sql来处理Hive的数据:今天任务由于数据量增大,任务耗时也增加,因此导致多个任务同时运行.但是后来任务迟迟运行不完,因此去查看任务日志: 16-08-20 ...
- java.sql.SQLException: null, message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to
迁移项目或是修改数据库密码后,项目访问数据库时报的这个异常.这个异常是数据库只允许localhost或127.0.0.1访问,不允许远程访问.我用的本机IP都不行. 解决办法:修改访问权限即可. 打开 ...
- 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 co ...
- 连接失败!null, message from server: “Host ‘xxxx‘ is not allowed to connect to this MySQL server“
命令后登陆数据库 mysql -uroot -proot show databases: use mysql ; select user,host from user; # 可以看到user为root ...
最新文章
- Pictures for active reading.Unit 1 Food and health.
- php psr2规范,php标准规范详解
- 完美解决Ubuntu16.04虚拟机窗口自适应问题
- html5 postMessage解决跨域、跨窗口消息传递[转载]
- Istio Proxy【Envoy扩展】详解
- 盒子box在网页中居中的方法
- 计算机硬件系统主机主要包括,组成计算机硬件系统的基本部分是什么?
- 弹幕视频播放app案例分析
- mipi传输距离3米_弱电网络工程中网线大于100米怎么办?离300米远用什么线缆较好?...
- 小学教师听课体会 计算机,小学教师观有效课堂听课心得体会
- 基于Proteus学习单片机系列(七)——实时时钟DS1302
- can收发器 rx_USB-CAN收发器
- mobiscroll插件滑动时间选择效果
- go1.17+中的GOPATH
- 《七堂极简物理课》总结
- 大数据进阶(二):数据可视化和分析工具推荐
- 《缠中说禅108课》90:中阴阶段结束时间的辅助判断
- 商城项目-商品规格参数管理
- 2021年电工(初级)考试报名及电工(初级)复审模拟考试
- 【毕业设计】深度学习车牌识别系统 - yolo python