mysql5.7 unknown auth plugin

Created on 6 Jun 2018  ·  20Comments  ·  Source: go-sql-driver/mysql

Issue description

Tell us what should happen and what happens instead
mysql5.7 unknown auth plugin

Example code

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

Error log

[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

Configuration

bug

Most helpful comment

I upgraded and got this error:

could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.

I'm using the proxy dialer with DialCfg from github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql, and in my case the simple fix was to add AllowNativePasswords in the config struct.

&mysqldriver.Config{ AllowNativePasswords: true, ... }

All 20 comments

The following section is also for a good reason in the issue template:

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

My guess is that your master branch is not the latest version. Please check the specific version with git rev-parse HEAD and sync and try again with the newer version if necessary.

hello,I also have this problem. Do you have resolved?

no

Does this branch fix the issue for you? https://github.com/go-sql-driver/mysql/tree/empty_auth

In any case, it would be great if you could insert a simple print(data) after this block https://github.com/go-sql-driver/mysql/blob/d523deb1b23d913de5bdada721a6071e71283618/packets.go#L157-L167 and here https://github.com/go-sql-driver/mysql/blob/d523deb1b23d913de5bdada721a6071e71283618/packets.go#L469-L474 and send us the resulting packet dump so that we can use it to create a regression test.

@gocuntian did you resolve the problem?

I have the same question, my question is my server send the init packet without the way of auth
accroding source code:
auth.go:240, in func auth(), add the code:
if plugin == "" {
plugin = "mysql_native_password"
}
my problem have been solved

I got the same warning when connecting to MySQL 5.1.

auth.go:293: unknown auth plugin:
driver.go:120: could not use requested auth plugin '': this authentication plugin is not supported

The branch https://github.com/go-sql-driver/mysql/tree/empty_auth fixed it. Do you have a plan to merge the branch? @julienschmidt

I have the same problem.
driver.go:113: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
Fails on master (go get)
Fails with v1.4.0
Works with v1.3.0

I could provide more info if you need it. Or do you think that is another problem and I should create a new issue?

Reopened. See #828 and #835 (PR for empty_auth branch)

I just want to highlight that there seem to be two problems here with very similar symptoms.

The fix in #835 appears to fix the case where there's an empty auth plugin name, but it doesn't solve the issue @mbertschler and I had with the mysql_native_password plugin (see https://github.com/go-sql-driver/mysql/issues/828#issuecomment-401856689 for further details).

Maybe that's a different issue, but I suspect a wider fix is required than that proposed in #835.

@kwoodhouse93 Can you send us a packet log, e.g. as described here: https://github.com/go-sql-driver/mysql/issues/815#issuecomment-396244978 (preferably using the empty_auth branch / #835)?

And also try adding &allowNativaPasswords=true to your DSN, just in case (it should be true by default)

Using empty_auth branch, I added print(data) in the places mentioned, and the output was:

[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.
...

That repeated 12 times before it stopped retrying, each with a slightly different address.

Regarding my DSN, I'm using mysql.Config with FormatDSN(). AllowNativePasswords was omitted when creating the Config struct, so I added AllowNativePasswords: true,. That changed the behaviour somewhat, but ultimately still returned the same error.

[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.

(Note, it didn't repeat this time. It just failed once and returned an error to my client app)

Looking at the output produced by print(data), were you hoping to see the contents of those addresses? Happy to try again if you can tell me how to get at it (would look myself, but I don't have much more time to spend on this today).

I upgraded and got this error:

could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.

I'm using the proxy dialer with DialCfg from github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql, and in my case the simple fix was to add AllowNativePasswords in the config struct.

&mysqldriver.Config{ AllowNativePasswords: true, ... }

This error was solved in my case by specifying AllowNativePasswords: true in the configuration

AllowNativePassword is true by default.
You shouldn't use Config{} to create config object. Use DSN or NewConfig().

https://godoc.org/github.com/go-sql-driver/mysql#Config

If a new Config is created instead of being parsed from a DSN string, the NewConfig function should be used, which sets default values.

Thanks. I was creating a Config because I read in the API docs, missed that step.

Was this page helpful?
0 / 5 - 0 ratings