文章目录 go 连接 mysql 问题go 连接 mysql 问题 参考官方文档 https://go.dev/doc/tutorial/database-access var db *sql.DBfunc main() {// Capture connection properties.cfg := mysql.Config{User: os.Getenv("DBUSER"),Passwd: os.Getenv("DBPASS…
zego@zegodeMacBook-Pro-53 data-access % go run main.go
[mysql] 2021/12/16 11:23:02 connector.go:95: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
2021/12/16 11:23:02 this user requires mysql native password authentication.
exit status 1
解决方法:添加 AllowNativePasswords: true,
1
2
3
4
5
6
7
8
cfg := mysql.Config{
User: os.Getenv("DBUSER"),
Passwd: "123456",
Net: "tcp",
Addr: "127.0.0.1:3306",
DBName: "recordings",
AllowNativePasswords: true,
}
参考文档中说明该参数默认为 true,我这边不知道何原因为 false 当设为 false 表示不允许使用 MySQL 原生密码方法
go 连接 mysql: could not use requested auth plugin ‘mysql_native_password‘
文章目录 go 连接 mysql 问题go 连接 mysql 问题 参考官方文档 https://go.dev/doc/tutorial/database-access var db *sql.DBfunc main() {// Capture connection properties.cfg := mysql.Config{User: os.Getenv("DBUSER"),Passwd: os.Getenv("DBPASS…