Fix 'this authentication plugin is not supported' issue while using Go to connect MySQL 8

  sonic0002        2018-07-11 08:55:02       15,291        4    

MySQL 8 has changed its default authentication plugin from mysql_native_password to caching_sha2_password to improve its security. However many third party libraries seem act slowly to catch up with this change. This causes some compatible issues with their connection to MySQL. One of the issues is seen in Go libraries while it's trying to connect to MySQL 8.

The specific error has been observed is "this authentication plugin is not supported". The root cause of this issue is that the go-sql-driver didn't support the new default authentication plugin. This bug has been reported a couple of months ago and it has been fixed in the latest release(1.4.0). The best advice to be given is to upgrade the go-sql-driver to 1.4.0 or above.  See the release note for 1.4.0.

Major Release

  • Multi-Results support
  • context.Context support
  • ColumnType support
  • caching_sha2_password (MySQL 8 default) and sha256_password authentication support
  • Transaction isolation level support
  • Read-Only transactions support
  • Many, many bugfixes

If for some reason the driver cannot be upgraded, there is a workaround can be applied which is to change the default authentication plugin back to mysql_native_password in mysql server configuration.

The location of the my.cnf can be found with below command

mysql --help | grep "Default options" -A 1 

The output will list the candidate locations of the my.cnf file. After locating the my.cnf file, you can update the [mysqld] section and add one line like below:

[mysqld]

# Only allow connections from localhost

bind-address = 127.0.0.1

default-authentication-plugin=mysql_native_password

Thereafter restart the mysqld service and you should be able to connect to MySQL 8 as usual. However, we still advise you to upgrade your driver to the latest one if possible.

GO  MYSQL 8  AUTHENTICATION PLUGIN  MYSQL 

       

  RELATED


  4 COMMENTS


Anonyaous [Reply]@ 2018-09-28 07:30:05

didn't work

Ke Pi [Reply]@ 2018-09-28 08:03:36

check how is your user password created, create it again if necessary

ris [Reply]@ 2021-09-29 08:44:53

Interestingly, the default-authentication-plugin workaround doesn't _always_ seem to work. When using _incorrect_ credentials, the "authentication plugin is not supported" error message seems to reappear, overriding the correct error message. Which may not be a massive issue to some, but sure screws up our unit tests :)

Ke Pi [Reply]@ 2021-10-02 01:44:08

thank u for sharing this info. nice to know



  RANDOM FUN

Doing KT before quitting