美文网首页
Can't connect to MySQL server on

Can't connect to MySQL server on

作者: 北京的天空 | 来源:发表于2018-10-26 15:07 被阅读0次

1.初学java链接数据库,出现

com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@3f72acc1 --
Acquisition Attempt Failed!!! Clearing pending acquires.

While trying to acquire a needed new resource, we failed to succeed more than   
the maximum number of allowed acquisition attempts (30). Last acquisition 
attempt exception:   

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

怀疑是数据库没链接成功!
查看eclispe端口号为3306,于是查看mysql的端口号,终端输入:

show global variables like 'port';

后显示:


image.png

果然不是3306 于是决定修改方法为

1.停止MySQL服务
2.在com.oracle.oss.mysql.mysqld.plist文件中的ProgramArguments下添加<string>--port=3306</string>保存退出
这里直接修改可能会提示没有权限
3.打开终端输入cd 到com.oracle.oss.mysql.mysqld.plist所在目录
输入

sudo vim  com.oracle.oss.mysql.mysqld.plist

编辑为如下图


image.png

保存
重启mysql

相关文章

网友评论

      本文标题:Can't connect to MySQL server on

      本文链接:https://www.haomeiwen.com/subject/ngoktqtx.html