Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置mysql建议把host:port写出来,不改默认连接本地mysql #33

Open
pcgoodboy opened this issue Mar 6, 2023 · 3 comments
Open
Labels
suggestion Product suggestion

Comments

@pcgoodboy
Copy link

2023/03/06 15:02:18 dial tcp: lookup 127.0.0.1:3306: no such host
panic: failed to connect database

默认127.0.0.0.1:3306
结果报错了,我以为是我的网络有问题,结果。。。。。
原来是我把后面两个数据库都写上了,因为平时只用过mysql和sqlite3,我就说怪了,怎么不指定端口?postgres不认识

driver: mysql
addr: root:root@tcp(host:port)/guora?charset=utf8&parseTime=True&loc=Local

@meloalright
Copy link
Owner

嗯呢 配置 mysql server 端地址也如 gorm 的写法一致就行

@meloalright
Copy link
Owner

这里确实也是透传

DB, err = gorm.Open(conf.Config().DB.Driver, conf.Config().DB.Addr)

@meloalright
Copy link
Owner

是个好建议 感谢

@meloalright meloalright added the suggestion Product suggestion label Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Product suggestion
Projects
None yet
Development

No branches or pull requests

2 participants