docker logs -f containter_id
Caused by: com.alibaba.nacos.api.exception.NacosException: Nacos Server did not start because dumpservice bean construction failure :
No DataSource set
進(jìn)一步查看 容器內(nèi)錯(cuò)誤日志 /home/nacos/logs/nacos.log
報(bào)錯(cuò)開(kāi)始行
2022-11-10 16:03:34,323 ERROR HikariPool-1 - Exception during pool initialization.
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
后面找到一行關(guān)鍵錯(cuò)誤
Caused by: com.mysql.cj.exceptions.CJException: Access denied for user 'root'@'host.docker.internal' (using password: YES)
一般來(lái)講本地?cái)?shù)據(jù)庫(kù)是不會(huì)放開(kāi)遠(yuǎn)程連接的 所以我這邊是新建一個(gè)用戶(hù) 并授權(quán) 開(kāi)始遠(yuǎn)程連接
創(chuàng)建nacos用戶(hù)
create user 'nacos'@'%' identified by '123456';
將nacos數(shù)據(jù)管理權(quán)限授權(quán)給nacos
grant all privileges on nacos.* to `nacos`@'%';
將新配置刷新到緩存中,這樣就不用重啟數(shù)據(jù)庫(kù)
flush privileges;
修改配置
application.properties文件文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-515180.html
#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://192.168.16.102:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos
db.password.0=123456
再次啟動(dòng)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-515180.html
到了這里,關(guān)于docker 啟動(dòng) nacos 連接本地?cái)?shù)據(jù)庫(kù) 踩坑的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!