go连接MySQL报错:this authentication plugin is not supported的解决

MySQL升级8.0以上版本后,用go连接MySQL会报错this authentication plugin is not supported,是因为MySQL8.0版本修改了加密方式,所以只要修改一下密码的加密方式就可以了。

进入root用户,修改root用户的密码和加密方式:这里修改密码为“root”

mysql> alter user root@localhost identified with mysql_native_password by 'root';
Query OK, 0 rows affected (0.13 sec)

mysql> 

查询MySQL用户:

mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| 127.0.0.1 | Tom              | caching_sha2_password |
| localhost | Tom              | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | mysql_native_password |
+-----------+------------------+-----------------------+
6 rows in set (0.00 sec)

mysql> 

修改其他用户:

mysql> alter user Tom@127.0.0.1 identified with mysql_native_password by '456789';
Query OK, 0 rows affected (0.03 sec)

mysql> 

查看:

mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| 127.0.0.1 | Tom              | mysql_native_password |
| localhost | Tom              | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | mysql_native_password |
+-----------+------------------+-----------------------+
6 rows in set (0.00 sec)

mysql> 

之后重启MySQL,再次连接就可以了。

猜你喜欢

转载自blog.csdn.net/Charliewolf/article/details/82556583