go
module_error
ai_generated
true
sql:未知的驱动程序"mysql"(忘记导入?)
sql: unknown driver "mysql" (forgotten import?)
ID: go/database-sql-unsupported-driver
80%修复率
90%置信度
0证据数
2024-06-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.17 | active | — | — | — |
根因分析
未导入数据库驱动程序,或驱动程序名称拼写错误。
English
The database driver is not imported, or the driver name is misspelled.
解决方案
-
95% 成功率
import _ "github.com/go-sql-driver/mysql"
-
90% 成功率
sql.Open("mysql", "user:password@tcp(host:port)/dbname")
无效尝试
常见但无效的做法:
-
80% 失败
Driver names are case-sensitive; 'MySQL' is not the same as 'mysql'.
-
70% 失败
Go requires a blank import to register the driver.