Skip to content

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

@wr125

Description

@wr125

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions