Navicat 连接MySQL8.0出现2059错误
来源:闲庭CC     阅读:580
动风网络
发布于 2018-12-25 22:49
查看主页

mysql8.0出现的2059 - authentication plugin 'caching_sha2_password' -navicat连接异常问题

问题形容:
在navicat链接mysql8以后的版本时会出现2059的错误,这个错误出现的起因是在mysql8之前的版本中加密规则为mysql_native_password,而在mysql8以后的加密规则为caching_sha2_password

处理方案:

  1. 将mysql8.0以后验证方式改为以前版本使用的验证方式mysql_native_password
    找到mysql对应的安装目录下my-default.ini文件,
    default_authentication_plugin=caching_sha2_password
    改为default_authentication_plugin=mysql_native_password
    以下是我的my-default.ini 的内容:
     [mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 basedir=C:\Program Files\MySQL\MySQL Server 8.0 # 设置mysql数据库的数据的存放目录 datadir=C:\Program Files\MySQL\MySQL Server 8.0\data # 允许最大连接数 max_connections=200 # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 max_connect_errors=10 # 服务端使用的字符集默认为UTF8 character-set-server=utf8 # 创立新表时将使用的默认存储引擎 default-storage-engine=INNODB # 默认使用“mysql_native_password”插件认证 default_authentication_plugin=mysql_native_password [mysql] # 设置mysql用户端默认字符集 default-character-set=utf8 [client] # 设置mysql用户端连接服务端时默认使用的端口 port=3306 default-character-set=utf8
  2. 管理员身份运行cmd(win10右键左下角开始按钮选择以管理员身份运行cmd就可)
  3. 以管理员身份运行cmd进入mysql的安装目录下的bin文件夹
    C:\>cd C:\Program Files\MySQL\MySQL Server 8.0\bin
  4. 假如C:\Program Files\MySQL\MySQL Server 8.0\bin 目录下没有data文件夹,执行以下命令:
    • 输入mysqld -install(假如不用管理员身份运行,将会由于权限不够而出现错误:Install/Remove of the Service Denied!)
    • 运行mysqld --initialize 就可,此时查看已有data文件夹。
  5. 登录数据库
    命令行执行mysql -u root -p 而后输入数据库密码,出现Welcome to the MySQL monitor. .. 字样则登录成功。
  6. 修改加密规则
    执行ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
  7. 升级一下客户的密码
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxx';
    其中的xxxxx 为新设置的密码。
  8. 刷新权限
    执行FLUSH PRIVILEGES;
  9. 而后打开Navicat连接Mysql,发现连接成功了,完美处理问题。
  10. 具体操作如下:
      C:\>cd C:\Program Files\MySQL\MySQL Server 8.0\bin  C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p  Enter password: ******  Welcome to the MySQL monitor.  Commands end with ; or \g.  Your MySQL connection id is 8  Server version: 8.0.13 MySQL Community Server - GPL    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.    Oracle is a registered trademark of Oracle Corporation and/or its  affiliates. Other names may be trademarks of their respective  owners.    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;  Query OK, 0 rows affected (0.07 sec)    mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'abcd';  Query OK, 0 rows affected (0.06 sec)    mysql> FLUSH PRIVILEGES;  Query OK, 0 rows affected (0.00 sec)    mysql>

经过一系列操作最终处理了问题,Navicat顺利连接Mysql。

免责声明:本文为用户发表,不代表网站立场,仅供参考,不构成引导等用途。 系统环境 服务器应用
相关推荐
前台面试每日 3+1 —— 第389天
Objective-C高级编程笔记一(自动引用计数)
[Android开发]- MVC的架构实现登录板块-1
前台面试每日 3+1 —— 第615天
这个软件每个人都用得到,关键时候能救命
首页
搜索
订单
购物车
我的