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
}
}