go 连接mysql 8.0

mysql8 为了提升安全性将默认的权限校验插件由mysql_native_password变更为caching_sha2_password,但是第三方链接库更新没有完全完成跟进。例如go在连接mysql8.0时会报错误“this authentication plugin is not supported”,根本原因在于go-sql-driver不支持新的校验方式。目前有三个解决方案:

1. 使用低版本的mysql

2. 更新最新的go驱动

3. 更改mysql默认权限校验方式,

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


    image.png
  • sudo vi /etc/my.cnf 添加内容:
    [mysqld]
    # Only allow connections from localhost
    bind-address = 127.0.0.1
    default-authentication-plugin=mysql_native_password

参考文章:

go 链接mysql 8.0

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容