当前位置:网站首页>数据库连接异常:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01问题处理
数据库连接异常:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01问题处理
2022-06-23 03:56:00 【卖柴火的小伙子】
今天项目中新增了一部分接口,本地测试好之后打包部署到测试环境,数据库竟然连接失败,报错信息如下:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01,这个报错信息的意思数数据库连接异常,相信很多人都遇到过,现在总接一下数据库远程连接遇到此问题的定位思路。
1.确定mysql进程是否正在运行
ps -ef|grep mysqld
如果没有运行,可以启动mysql,启动方式:
service mysql start
sudo service mysqld start
不同的安装方式启动命令会有不同,可以参考:超详细的linux部署mysql5.7实战记录
2.本地尝试连接mysql看一下是否能连接成功
win+r,输入cmd,进入黑窗口命令行,输入命令:
msyql -h 远程数据库所在服务器的ip -u root -p
然后输入密码,如果不能登录,需要重新检查一下数据库的连接信息,注意一下要连接的数据库名、数据库端口是否正确(一般默认端口是3306)、mysql数据库允许访问连接是否是只允许某个ip还是所有。这主要是看一下数据库的配置文件my.cnf中的配置信息。
另外看一下mysql数据库中user表中host的地址,默认是localhost,即只能本机访问,不允许远程连接。
查看方式:
USE mysql;
SELECT * FROM USER

host设置为%,表示是允许root用户在任意ip下访问。如果上面都没有问题,继续往下看。
3.阿里云ecs服务器安全组设置
只要是部署在阿里云的应用,都需要到安全组中设置开放端口允许访问的ip。在实际开发中,对于部署在阿里云上的mysql数据库来讲,需要对数据库端口添加两条记录,一个是对mysql数据库本身允许访问,即对应的ip是阿里云服务器地址;另一个是对指定的应用服务器所在服务器ip开启。
我这边出现问题原因就是安全组设置中数据库端口3306只有一条记录,只对java项目所在服务器ip开放,新增一条mysql所在服务器ip记录后问题解决。
以上是对数据库连接异常的问题排查思路总结,如果对你有帮助欢迎点赞收藏或是评论区留言!
边栏推荐
- Hcip fifth operation
- 弱者易怒如虎,强者平静如水,真正厉害的人早已戒掉了情绪
- 小时候 觉得爸爸就是天 无所不能~
- Swiftui 2.0 course notes Chapter 4
- TIOBE 编程语言排行榜是编程语言流行趋势的一个指标
- What is the average annual salary of an outsourced tester who has worked for 5-8 years?
- JDBC入门学习(一)之DML操作
- The tiobe programming language ranking is an indicator of the popular trend of programming languages
- MCS: discrete random variable
- MySQL stored procedure
猜你喜欢

Master shell, one article is enough!

Zygote process

【微服务|Nacos】Nacos版本相关问题一览

Introduction and use of precise ephemeris

Baidu PaddlePaddle's "universal gravitation" first stop in 2022 landed in Suzhou, comprehensively launching the SME empowerment plan

物联网开源开发平台 Shifu 开放内测!第一版技术文档发布

Event日志关键字:EventLogTags.logtags

UnityShader入门精要——Unity中的渲染优化技术(四)

markdown给图片加背景色

onnxoptimizer、onnxsim使用记录
随机推荐
ES6的Array.from方法创建长度为N的undefined数组
One or more lines of text overflow, ellipsis instead
STP summary
Swiftui 2.0 course notes Chapter 5
(IntelliJ) plug in background image plus
Open source ecology 𞓜 super practical open source license basic knowledge literacy post (Part 2)
What is the average annual salary of an outsourced tester who has worked for 5-8 years?
When SBAS encounters rtklib
大環境不好難找工作?三面阿裏,幸好做足了准備,已拿offer
104. 简易聊天室7:使用 Socket 传递对象
Three methods of GNSS velocity calculation
Go 分组 & 排序
UI automation positioning edge -xpath actual combat
JDBC入门学习(三)之事务回滚功能的实现
How can functional testers spend one month to become advanced automation software test engineers
MySQL stored procedure
牛B程序员在“创建索引”时都会注意啥?
关于信息泄露和防御
关于DOS/DDOS攻击和防御
Post processing of multisensor data fusion using Px4 ECL