Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wr125 opened this issue Aug 22, 2021 · 10 comments

Comments

@wr125
Copy link

wr125 commented Aug 22, 2021

Issue description

On following golang's tutorial on what to use go-mysql https://golang.org/doc/tutorial/database-access i get the error message on go run . When I type in mysql -u I get Access denied for user 'james'@'localhost' (using password: NO)

Think it might have to do with	Addr:   "127.0.0.1:3306", in config is not the same as localhost auth/password?


### Example code
```go
example code can be found https://play.golang.org/p/35hwCb4bJ6H

Error log

ERROR 1045 (28000): Access denied for user 'james'@'localhost' (using password: NO)

go run .
[mysql] 2021/08/22 14:30:22 connector.go:95: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
2021/08/22 14:30:22 this user requires mysql native password authentication.
I have tried mysql -u root -p -h 127.0.0.1 -P 3306
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
also tried; telnet localhost 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
[
5.7.35-0ubuntu0.18.04.1
                       N7(z�3����x*k/�+�OSb:umysql_native_passwordConnection closed by foreign host.

mysqladmin -h localhost variables
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'james'@'localhost' (using password: NO)'

Configuration

Driver version (or git SHA): - unknown

Go version: run go version 1.17

Server version: E.g. MySQL 5.6,

Server OS: E.g. linux mint . 5.7.35-ubuntu 18.04.1

@methane
Copy link
Member

methane commented Aug 24, 2021

	// Capture connection properties.
	cfg := mysql.Config{
		User:   os.Getenv("DBUSER"),
		Passwd: os.Getenv("DBPASS"),
		Net:    "tcp",
		Addr:   "127.0.0.1:3306",
		DBName: "recordings",
	}

This is a bug. See https://pkg.go.dev/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.

In other words, you didn't use default value.

@methane methane closed this as completed Aug 24, 2021
@wr125
Copy link
Author

wr125 commented Aug 24, 2021

Could you post example code for the record please and thanks.

@torenware
Copy link

PLEASE REOPEN THIS. @methane you are full of gas!! You mention there is a bug, you do not give a work around, and you close the bug. Please do not do this. This seems to be a pattern in your issue queue.

This is not a usable driver right now on MacOS, and possibly other OS.

@methane
Copy link
Member

methane commented Feb 26, 2022

PLEASE REOPEN THIS.

READ MY REPLY CAREFULLY.

@methane you are full of gas!!

I don't know what "full of gas" mean.

You mention there is a bug, you do not give a work around, and you close the bug.

I mentioned the bug is in the example code above.
In the same reply, I clearly noted why it is a bug and how to solve it.

Please do not do this. This seems to be a pattern in your issue queue.

Yes, it is a pattern in this issue tracker. Many users don't read document carefully. They believe bug in this driver, not in their code. And they ask such questions as maintainers should be free tech support.

This is very big issue about OSS sustainability. You should do:

  • Suspect bug in your code, not in the widely used, stable, production quality libraries.
  • Read the document, before creating new issue on the issue tracker.
  • When you can't solve your problem by yourself, ask question in community before creating new issue in the issue tracker.

@torenware
Copy link

@methane: I do know that OSS work can be thankless at times, and I am sorry if I burdened you unduly.

But I do think you are closing down issues too quickly. It's possible that some of the issues here are upstream. But people will experience them first via your code. I'm not surprised why these issues appear in your queue, for that reason. But very arguably, when upstream issues dribble downwards into code you create, it's important that a library be coded defensively to keep code that relies upon your library stable.

When you repeated get similar issues reported on your queue, rather than condemn your users, see if you can be of help. As a concrete example, look at your comment above:

This is a bug. See https://pkg.go.dev/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.

In other words, you didn't use default value.

First of all, your link was not directly on point. It's unclear what you were referring to, In particular, what default value you were talking about. You recommend using the mysql.NewConfig API. But it's unclear how; having tried it, I got different backend responses, depending upon how I used it.

A small amount of sample code would have helped your user, made clear how to work around the upstream bug you refer to, and frankly, would have been much kinder on your part.

I don't want to be overly hard on you, but this is a frustrating library to deal with, since the user queue is getting shut down because you are not taking your users' issues seriously. If you'll be a bit more positive about the feedback, possibly your users will also be more positive and perhaps more helpful to other users in issues. Or in terms of submitting patches.

@methane
Copy link
Member

methane commented Feb 26, 2022

When you repeated get similar issues reported on your queue, rather than ‎ condemn ‎ your users, see if you can be of help.

No. I don't want to be a free tech support.

First of all, your link was not directly on point. It's unclear what you were referring to, In particular, what default value you were talking about.

If you read it carefully, it is very clear.

  • Issue title is "this user requires mysql native password authentication"
  • I said to use NewConfig() instead of Config to use default value.

Then you must know the default value means something allowing native password. (But not only it. Default values including some others. See code for detail.)

And if you click the link, you must see this member in Confg:

AllowNativePasswords    [bool](https://pkg.go.dev/builtin#bool) // Allows the native password authentication method

You must see it by using your 3 minutes.

On the other hand, I needed to more than 20 minutes for this reply. Note that I am not native English speaker and I am not good at English.

This is why I don't want to be "free tech support". DO NOT blame maintainers when you feel they not kind enough. Motivation and time is very limited resource for OSS sustainability.
As you can see other maintainers of this project don't actively maintain issues.

Of course, I don't close issues when issue report include enough information to suspect this driver.

If you'll be a bit more positive about the feedback, possibly your users will also be more positive and perhaps more helpful to other users in issues.

As my long life as OSS maintainer, this is not true. Users don't watch all issues on issue tracker. They watch only issue they subscribe. Only maintainer read all issues.

That's why I asked to "ask such question in Go or MySQL community."

On Gophers Slack, golang-nuts mailing list, many kind Gophers can help you.

@dusanbrankov

This comment was marked as spam.

@methane
Copy link
Member

methane commented Apr 30, 2024

DO NOT WRITE BAD ANSWER!!

I said don't use mysq.Config{}. Use mysql.NewConfig() instead.
Even if you can use native passwords by the sample code, you and users reading your comment may face another issue.

Use mysql.NewConfig() and read the manual. That's all.

@dusanbrankov
Copy link

Calm down, methane, I didn't mean to upset you that much. I just wanted to spare other Go beginners the frustration they will have following the instructions of the mentioned Go tutorial on their official website. When searching for the bug, this page is one of the first results.

I was also explicitly addressing only those people coming from this tutorial who may not have the knowledge yet to know how to replace the given struct with the NewConfig() function as you suggested; just reading the documentation without knowing how to implement it correctly will not help beginners like me.

@methane
Copy link
Member

methane commented Apr 30, 2024

Wrong advice doesn't help beginners. Beginners should learn how to use the API correctly.

@go-sql-driver go-sql-driver locked as too heated and limited conversation to collaborators Apr 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants