Categories
golang Mariadb

Go mysql config

I found that when using mysql.Config, I need to add AllowNativePasswords: true for a connection to mariadb from my go program

 30 cfg := mysql.Config{
 31         User: os.Getenv("DBUSER"),
 32         Passwd: os.Getenv("DBPASS"),
 33         Net: "tcp",
 34         Addr: "172.18.0.6:3306",
 35         AllowNativePasswords: true,
 36         DBName: "recordings",
 37     }
 ...
 42 db, err = sql.Open("mysql",cfg.FormatDSN())

Leave a Reply

Your email address will not be published. Required fields are marked *