MySql `caching_sha2_password`问题

540 阅读1分钟

MySQL 5.7之后,默认的default_authentication_plugincaching_sha2_password

在MySQL 5.7中,默认的default_authentication_pluginmysql_native_password

导致5.7之后的的MySQL与Sequel Pro、Navicat Premium存在兼容问题,连接不上。

一开始是在Homebrew下安装的MySQL,已更新到最新,第一个问题是,忘记密码了,需要重新改密码,改完密码,成功连上,但是用 Sequel Pro连不上,问题所在是caching_sha2_password,所以需要将default_authentication_plugin字段默认的caching_sha2_password改为mysql_native_password


一、尝试一

方法一(不成功):

  1. 查看default_authentication_plugin

    mysql> SHOW VARIABLES LIKE 'default_authentication_plugin';
    +-------------------------------+-----------------------+
    | Variable_name                 | Value                 |
    +-------------------------------+-----------------------+
    | default_authentication_plugin | caching_sha2_password |
    +-------------------------------+-----------------------+
    
  2. 修改(不成功,提示只读)

     mysql> set @@default_authentication_plugin='mysql_native_password';
     ERROR 1238 (HY000): Variable 'default_authentication_plugin' is a read only variable
    

方法二(不成功):

etc目录下新增my.cnf文件,在文件中添加:

default_authentication_plugin=mysql_native_password

没有起到效果,但是理论上应该是可以的才对。


二、卸载之前的MySQL

$ brew uninstall mysql

三、下载MySQL Server

  1. MySQL Community Server 8.0.x一路next,选择密码认证方式的时候选择旧的验证方式(Use Legacy Password Encryption)即可(可修改)。
  2. 具体步骤参考链接

四、Sequel Pro

数据库正常之后,通过Sequel Pro连接数据库成功,但是有报错,用不了。 大家都说用测试版本,亲测有效。


五、Navicat Premium

也可以选择Navicat Premium