TLDR; Error attempting to access DB with Golang
I am trying to connect to my localhost db using the example here. The go code for connecting to the DB can be found below.
func main() {
    // Capture connection properties.
    cfg := mysql.Config{
        User:   os.Getenv("DBUSER"),
        Passwd: os.Getenv("DBPASS"),
        Net:    "tcp",
        Addr:   "127.0.0.1:3306",
        DBName: "someDB",
    }
    // Get a database handle.
    var err error
    db, err = sql.Open("mysql", cfg.FormatDSN())
    if err != nil {
        log.Fatal(err)
    }
    pingErr := db.Ping()
    if pingErr != nil {
        log.Fatal(pingErr)
    }
    fmt.Println("Connected!")
}
I see the this output
✗ go run main.go
2023/02/17 00:10:35 Error 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I have tried:
- confirmed that DBUSERandDBPASSare set with the expected value
- I am able to mysql -u root -pand connect to DB without any issues.
 
    