Sql: unknown driver "mysql" (forgotten import?)

Hi every one, What is wrong with my code

when i try to run it, this show me this error, i put the driver of mysql in this path go/src/

Hey @RafaelGopher,

Try installing the go-sql-driver/mysql driver with go get github.com/go-sql-driver/mysql and then using _ "github.com/go-sql-driver/mysql" as an import and see if that works instead.

You can check it out here if you like: https://github.com/go-sql-driver/mysql.

You would also open it with this db, err := sql.Open("mysql", "user:password@/dbname"), but here are their examples if you want to try it: https://github.com/go-sql-driver/mysql/wiki/Examples.

1 Like

Thank you pal, it works

Glad to hear :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.