du5910 2018-03-01 13:49
浏览 11
已采纳

在Go中连接到db mysql

I am currently working oin a project in go. I need to connect to mysql db and do some stuff. Currently, i am having trouble with the connection.

First, i load and store the db crdentials from various possible sources (CLI, config file or startup parameter, depending on situation)

dbCredentials = DatabaseCredentials{DRIVER_NAME,BOT_LOGIN_NAME + ":" + BOT_PASSWORD + "@tcp(" + HOST_NAME + ")/" + NAME_OF_DB}

Later i try to open the connection:

db, err := sql.Open(dbCredentials.driverName, dbCredentials.dataSourceName) 
checkErr(err)
defer db.Close()

But i always get Error 1045: Access denied for user 'bot'@'127.0.0.1' (using password: YES)

The weird thing is the very same section of code used to work a couple of days ago and i am not aware of any changes that could cause this behaviour. I also didnt make any changes on the database.

Do you have any idea what i am doing wrong? Some input regarding what to look at for finding the error would be helpful.

  • 写回答

1条回答 默认 最新

  • doubaomao9304 2018-03-09 13:32
    关注

    Problem has disappeared as mysteriously as it appeared.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料