当前位置:网站首页>数据库连接异常: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记录后问题解决。
以上是对数据库连接异常的问题排查思路总结,如果对你有帮助欢迎点赞收藏或是评论区留言!
边栏推荐
- 985 test engineer is hanged. Who is more important in terms of education and experience?
- Missing essential plugin
- MCS: continuous random variable - student's t distribution
- ES6的Array.from方法创建长度为N的undefined数组
- Drama asking Huamen restaurant Weng
- Open source ecology 𞓜 super practical open source license basic knowledge literacy post (Part 2)
- Penetration test basis | attached test points and test scenarios
- 同步国内AOSP代码相关错误
- UI automation positioning edge -xpath actual combat
- Swiftui 2.0 course notes Chapter 4
猜你喜欢

九九乘法表.bat

开源生态|超实用开源License基础知识扫盲帖(下)

渗透测试基础 | 附带测试点、测试场景

Web application security testing guide

8 years' experience: monthly salary of 3000 to 30000, the change of Test Engineer

konva 系列教程 1:konva 是什么?

左侧固定,右侧自适应 三种实现办法(Flex,float + BFC ,float-margin-left)

Introduction to unityshader -- rendering optimization technology in unity (IV)

Image noise reduction denoise AI

大環境不好難找工作?三面阿裏,幸好做足了准備,已拿offer
随机推荐
开源生态|超实用开源License基础知识扫盲帖(下)
shutdown关机命令
BGP second test
MCS:离散随机变量
99 multiplication table bat
C'est dur de trouver un emploi? Ali des trois côtés, heureusement qu'il s'est bien préparé et qu'il a pris un produit.
Open source ecology 𞓜 super practical open source license basic knowledge literacy post (Part 2)
The tiobe programming language ranking is an indicator of the popular trend of programming languages
What do Niu B programmers pay attention to when "creating an index"?
App hangs~
Mysql入门学习(三)之视图
Arduino flame sensor (with code)
JVM原理之完整的一次GC流程
计算欧式距离和余弦相似度
Post processing of multisensor data fusion using Px4 ECL
小时候 觉得爸爸就是天 无所不能~
IDEA 代码开发完毕后,提交代码,提交后发现分支不对,怎么撤回
弱者易怒如虎,强者平静如水,真正厉害的人早已戒掉了情绪
How can functional testers spend one month to become advanced automation software test engineers
MCS: discrete random variable Bernoulli distribution