Erlo

nacos配置中心连接mysql8.0

2019-06-13 16:02:27 发布   1590 浏览  
页面报错/反馈
收藏 点赞

nacos配置中心连接mysql8.0

nacos连接mysql5.7正常,但是连接mysql8.0(mysql5.8)就提示错误。

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)

连接mysql5.7没问题。说明连接驱动版本有问题(为什么直接这么说呢,因为之前项目中mysql升级遇见过相同问题)。

把Nacos 自带mysql-connector-java 版本升级以下就可以了,从5.1.34升级到5.1.47。

1、首先 git clone https://github.com/alibaba/nacos.git

 

2、如果速度慢,设置hosts。

修改 C:WindowsSystem32driversetc。

151.101.185.194 github.global.ssl.fastly.net
192.30.253.112 github.com

 

3、接着下载后执行

先把版本修改

 

然后执行打包命令

cd nacos/ mvn -Prelease-nacos clean install -U

ls -al distribution/target/

// change the $version to your actual path

cd distribution/target/nacos-server-$version/nacos/bin

 

修改启动配置文件

nacosdistributiontargetnacos-server-1.0.1nacosconfapplication.properties

末尾添加:

spring.datasource.platform=mysql

db.num=1

db.url.0=jdbc:mysql://localhost:3306/nacos_devtest?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true

db.user=nacos_devtest

db.password=youdontknow

 

接着建库,执行mysql脚本

nacosdistributiontargetnacos-server-1.0.1nacosconfnacos-mysql.sql

接着你就可以启动bin文件夹下的 startup.cmd

浏览器访问http://127.0.0.1:8848/nacos

默认账号和密码:nacos

 

参考链接;https://nacos.io/zh-cn/docs/what-is-nacos.html

登录查看全部

参与评论

评论留言

还没有评论留言,赶紧来抢楼吧~~

手机查看

返回顶部

给这篇文章打个标签吧~

棒极了 糟糕透顶 好文章 PHP JAVA JS 小程序 Python SEO MySql 确认