Closed as not planned
Description
What is the URL of the page with the issue?
https://go.dev/doc/tutorial/database-access
What is your user agent?
Screenshot
What did you do?
I am following this Tutorial: Accessing a rational database
In the first place when we try to run the main.go to file with the below code
var db *sql.DB
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: "recordings",
}
// 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!")
}
many folks getting error when main.go file execute. the error getting is : This user requires MySQL native password authentication.
What did you expect to see?
I expect to see the MySQL database is connected with the Go code.
What did you see instead?
Instead of a connected database, I am getting this user requires MySQL native password authentication.
this error and database connection is refused when we run main.go file.