go-sql-driver/mysql · error
invalid value / unknown config name: %s
Error message
invalid value / unknown config name: %s
What it means
Error "invalid value / unknown config name: %s" thrown in go-sql-driver/mysql.
Source
Thrown at dsn.go:210
} else if cfg.Net == "tcp" {
cfg.Addr = ensureHavePort(cfg.Addr)
}
if cfg.TLS == nil {
switch cfg.TLSConfig {
case "false", "":
// don't set anything
case "true":
cfg.TLS = &tls.Config{}
case "skip-verify":
cfg.TLS = &tls.Config{InsecureSkipVerify: true}
case "preferred":
cfg.TLS = &tls.Config{InsecureSkipVerify: true}
cfg.AllowFallbackToPlaintext = true
default:
cfg.TLS = getTLSConfigClone(cfg.TLSConfig)
if cfg.TLS == nil {
return errors.New("invalid value / unknown config name: " + cfg.TLSConfig)
}
}
}
if cfg.TLS != nil && cfg.TLS.ServerName == "" && !cfg.TLS.InsecureSkipVerify {
host, _, err := net.SplitHostPort(cfg.Addr)
if err == nil {
cfg.TLS.ServerName = host
}
}
if cfg.ServerPubKey != "" {
cfg.pubKey = getServerPubKey(cfg.ServerPubKey)
if cfg.pubKey == nil {
return errors.New("invalid value / unknown server pub key name: " + cfg.ServerPubKey)
}
}
View on GitHub (pinned to 03d76c7e07)
Solutions
- Use a registered TLS config name in tls=<name>, or one of the built-in values: true, false, skip-verify, preferred.
- Register your custom TLS config first with mysql.RegisterTLSConfig(name, tlsConfig) before opening the connection.
Example fix
mysql.RegisterTLSConfig("custom", &tls.Config{RootCAs: roots})
dsn := "user:pass@tcp(dbhost:3306)/mydb?tls=custom" When it happens
Trigger: The DSN sets tls=<value> to a name that is not 'true', 'false', 'skip-verify', 'preferred', or a TLS config previously registered with mysql.RegisterTLSConfig.
Common situations: Typo in the tls parameter, or using a custom TLS config name without calling mysql.RegisterTLSConfig(name, config) before opening the connection. Register the config or use one of the built-in values.
AI-assisted analysis of go-sql-driver/mysql@03d76c7e07 (2026-08-07).
Data as JSON: /api/errors/9e70c950352350d1.
Report an issue: GitHub.