告诉我们应该发生什么,而不是发生什么
mysql5.7未知身份验证插件
// version go1.10.2 darwin/amd64
db, err := sql.Open("mysql", "admin:admin@tcp(127.0.0.1:9696)/test")
if err != nil {
fmt.Println("failed to open database:", err.Error())
return
}
defer db.Close()
rows, err := db.Query("SELECT id,str FROM test_shard_hash")
if err != nil {
fmt.Println("fetech data failed:", err.Error())
return
}
defer rows.Close()
for rows.Next() {
var id int
var str string
rows.Scan(&id, &str)
fmt.Println("uid:", id, "name:", str)
}
[mysql] 2018/06/06 22:15:07 auth.go:293: unknown auth plugin:
[mysql] 2018/06/06 22:15:07 driver.go:120: could not use requested auth plugin '': this authentication plugin is not supported
驱动程序版本(或git SHA):原始版本/主版本
Go版本:go1.10.2 darwin / amd64
服务器版本:MySQL 5.7
服务器操作系统:macOS 10.13.4(17E202)
以下部分也是问题模板中的一个很好的理由:
### Configuration
*Driver version (or git SHA):*
*Go version:* run `go version` in your console
*Server version:* E.g. MySQL 5.6, MariaDB 10.0.20
*Server OS:* E.g. Debian 8.1 (Jessie), Windows 10
我的猜测是您的master分支不是最新版本。 请使用git rev-parse HEAD
检查特定版本并进行同步,如有必要,请尝试使用较新的版本。
你好,我也有这个问题。 你解决了吗
不
该分支机构可以为您解决问题吗? https://github.com/go-sql-driver/mysql/tree/empty_auth
无论如何,如果您可以在此代码段之后插入一个简单的print(data)
那就太好了https://github.com/go-sql-driver/mysql/blob/d523deb1b23d913de5bdada721a6071e71283618/packets.go#L157 -L167然后在这里https://github.com/go-sql-driver/mysql/blob/d523deb1b23d913de5bdada721a6071e71283618/packets.go#L469 -L474并将结果数据包转储发送给我们,以便我们可以使用它创建回归测试。
@gocuntian您解决了这个问题吗?
我有同样的问题,我的问题是我的服务器发送的init数据包没有经过auth的方式
附加源代码:
auth.go:240,在func auth()中,添加代码:
如果插件==“” {
plugin =“ mysql_native_password”
}
我的问题已经解决了
连接到MySQL 5.1时,我得到了同样的警告。
auth.go:293: unknown auth plugin:
driver.go:120: could not use requested auth plugin '': this authentication plugin is not supported
分支机构https://github.com/go-sql-driver/mysql/tree/empty_auth对其进行了修复。 您有合并分支的计划吗? @julienschmidt
我也有同样的问题。
driver.go:113: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
未能掌握(去得到)
v1.4.0失败
适用于v1.3.0
如果您需要,我可以提供更多信息。 还是您认为这是另一个问题,我应该提出一个新的问题?
重新打开。 参见#828和#835( empty_auth
分支的PR)
我只想强调一下,这里似乎有两个问题,它们的症状非常相似。
#835中的修复程序似乎可以解决auth插件名称为空的情况,但无法解决@mbertschler的问题,而我使用的是mysql_native_password
插件(请参阅https://github.com/详情请参阅go-sql-driver / mysql / issues / 828#issuecomment-401856689)。
也许这是一个不同的问题,但是我怀疑需要比#835中提出的更广泛的修复程序。
@ kwoodhouse93您能否向我们发送一个数据包日志,例如,如下所述: https : empty_auth
分支/第835章)
并尝试将&allowNativaPasswords=true
到您的DSN中,以防万一(默认情况下应为true
)
使用empty_auth
分支,在上述位置添加了print(data)
,输出为:
[74/4092]0xc42036c004[mysql] 2018/07/13 11:49:18 driver.go:123: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
[74/4092]0xc420371004[mysql] 2018/07/13 11:49:26 driver.go:123: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
...
在停止重试之前,它重复了12次,每次的地址都略有不同。
关于我的DSN,我使用mysql.Config
和FormatDSN()
。 AllowNativePasswords
创建时省略Config
结构,所以我加AllowNativePasswords: true,
。 这在某种程度上改变了行为,但最终仍然返回了相同的错误。
[74/4092]0xc420294004[7/4092]0xc420294004S[74/4092]0xc4201bb004[mysql] 2018/07/13 11:53:13 driver.go:123: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
(请注意,这次没有重复。它仅失败一次,并向我的客户端应用返回了错误)
查看print(data)
产生的输出,您是否希望看到这些地址的内容? 如果您能告诉我如何进行操作,很高兴再试一次(请自己看一下,但是今天我没有太多时间花在这上面)。
我升级并收到此错误:
could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
我正在使用来自github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql的DialCfg代理拨号器,在我的情况下,简单的解决方法是在config结构中添加AllowNativePasswords。
&mysqldriver.Config{
AllowNativePasswords: true,
...
}
@mglonnro参见https://github.com/go-sql-driver/mysql/issues/815#issuecomment -425704501
在我的情况下,通过在配置中指定AllowNativePasswords: true
解决了此错误
默认情况下,AllowNativePassword为true。
您不应该使用Config{}
创建配置对象。 使用DSN或NewConfig()
。
https://godoc.org/github.com/go-sql-driver/mysql#Config
如果创建新配置而不是从DSN字符串中解析新配置,则应使用NewConfig函数,该函数将设置默认值。
谢谢。 我正在创建Config
因为我在API文档中阅读了该步骤。
最有用的评论
我升级并收到此错误:
could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
我正在使用来自github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql的DialCfg代理拨号器,在我的情况下,简单的解决方法是在config结构中添加AllowNativePasswords。
&mysqldriver.Config{ AllowNativePasswords: true, ... }