drd99007 2017-05-25 12:43
浏览 146

下面的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
    }
}
  • 写回答

1条回答 默认 最新

  • dongsheng8664 2017-05-25 15:19
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加