I’ve recently started self teaching Go and have run into this error, perhaps I’m not understanding the correct function of the mysql driver used in the Golang tutorial for db connection.
db, err := sql.Open("mysql", "user:pass@tcp(mywebserver)/networking_test")
The error is returning my local ip address stating access denied while using password. Is the SQL query never leaving my network? Full code provided below, full error included below that.
package main
import (
"fmt"
"database/sql"
_ "mysql"
)
func main() {
fmt.Println("Go MySQL Tutorial")
db, err := sql.Open("mysql", "user:npass@tcp(mywebserver)/networking_test")
if err != nil {
panic(err.Error())
}
defer db.Close()
dbuser, err := db.Query("SELECT user FROM authentication")
if err != nil {
panic(err.Error())
}
defer dbuser.Close()
}
//Error - panic: Error 1045: Access denied for user 'networkuser'@'LOCALHOST(using password: YES)