下面的golang代码在已编译的系统上可以正常工作,但是当

The below golang code works fine on the system compiled, however when the compiled binary is moved to another system it fails to connect database. What thing I am doing wrong here in terms of packaging.

package main

import (
      "fmt"
      "database/sql"
    _ "github.com/go-sql-driver/mysql"
      "time"
      "os"
)

func main() {

        // Open database connection
    db, err := sql.Open("mysql", "root:passwd@/mysql")
    if err != nil {
        fmt.Printf("Cannot open connection to schema !!!. 
")
        return
    }
    defer db.Close()

    // Execute the query
    rows, err := db.Exec("update user set password=PASSWORD("NEWPASSWORD") where User='root'")
    _ = rows
    if err != nil {
        fmt.Printf("Cannot execute query update !!! 
")
        return
    }
}

The issue got resolved. The problem was with support for legacy old password authentication. Had to add append

db, err := sql.Open("mysql", "root:passwd@/mysql?allowOldPasswords=1")

https://github.com/go-sql-driver/mysql/wiki/old_passwords