首页 > 数据库 >MySQL8.0登录提示caching_sha2_password问题解决方法

MySQL8.0登录提示caching_sha2_password问题解决方法

时间:2022-12-11 10:00:47浏览次数:76  
标签:sha2 MySQL8.0 mysql caching password root localhost

背景

用​​docker​​构建mysql容器后连接遇到以下问题

问题

Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found

mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]

mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client

解决方法1(docker)

适用场景

  1. 第一次构建容器/安装
  2. 已安装完成后新增用户

配置

配置 mysql.cnf 配置默认身份验证插件

[mysqld]

default_authentication_plugin = mysql_native_password

验证是否生效

使用CLI进入MySQL

$ mysql -u root -p

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Database changed

mysql> SELECT Host, User, plugin from user;

+-----------+------------------+-----------------------+

| Host      | User             | plugin                |

+-----------+------------------+-----------------------+

| %         | root             | mysql_native_password |

| localhost | mysql.infoschema | caching_sha2_password |

| localhost | mysql.session    | caching_sha2_password |

| localhost | mysql.sys        | caching_sha2_password |

| localhost | root             | mysql_native_password |

+-----------+------------------+-----------------------+

5 rows in set (0.00 sec)

root用户的身份验证器插件已经变为:mysql_native_password

解决方法2

适用场景

  1. MySQL 已成功安装完成后

查看身份验证类型

mysql> use mysql;

Database changed


mysql> SELECT Host, User, plugin from user;

+-----------+------------------+-----------------------+

| Host      | User             | plugin                |

+-----------+------------------+-----------------------+

| %         | root             | caching_sha2_password |

| localhost | mysql.infoschema | caching_sha2_password |

| localhost | mysql.session    | caching_sha2_password |

| localhost | mysql.sys        | caching_sha2_password |

| localhost | root             | caching_sha2_password |

+-----------+------------------+-----------------------+

5 rows in set (0.00 sec)

​root​​ 用户的验证器插件为 caching_sha2_password

修改身份验证类型(修改密码)

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

Query OK, 0 rows affected (0.00 sec)


mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

Query OK, 0 rows affected (0.01 sec)

使生效

mysql> FLUSH PRIVILEGES;

验证是否生效

mysql> SELECT Host, User, plugin from user;

+-----------+------------------+-----------------------+

| Host      | User             | plugin                |

+-----------+------------------+-----------------------+

| %         | root             | mysql_native_password |

| localhost | mysql.infoschema | caching_sha2_password |

| localhost | mysql.session    | caching_sha2_password |

| localhost | mysql.sys        | caching_sha2_password |

| localhost | root             | mysql_native_password |

+-----------+------------------+-----------------------+

5 rows in set (0.00 sec)

标签:sha2,MySQL8.0,mysql,caching,password,root,localhost
From: https://blog.51cto.com/u_12285298/5928108

相关文章

  • 绿色版MySQL8.0.26安装流程
    下载 5.7 8.0 官网 https://dev.mysql.com/downloads/mysql/ 国内镜像网站 https://developer.aliyun.com/mirror/ ​ windows安装数据库 安装版: .......
  • MySQL8.0的caching_sha2_password问题
    问题描述及分析安装MySQL8.0后,使用MySQLWorkbench登录时报以下错误分析及查找相关资料后,发现MySQL8.0采用了新的更安全的验证方式,详情请查看​​mysql-8-0-4-new-default-......
  • Mysql8.0.25安装过程
    步骤一.下载mysql8.0.25步骤二.下载完解压后如下图:  图片中显示可知,并没有exe用来安装,那么请看第三步步骤三.创建一个txt文本文件,将下边的......
  • mysql8.0使用总结
    1.初始化数据库后,想导入数据,发现报错:ERROR1227(42000)atline75612:Accessdenied;youneed(atleastoneof)theSYSTEM_USERprivilege(s)forthisoperatio......
  • 1+N环境MySQL8.0.29/30版本BUG处理措施
    背景:前期安全漏扫后,1+N环境中部分MySQL8.0数据库由低版本通过upgrade方式升级到8.0.29版本,后又升级到8.0.30版本。此版本的upgrade升级方式,在执行altertableaddcolmun......
  • 0132-Go-SHA256
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/sha256-hashes目标使用Go语言的SHA256。示例packagemainimport("crypto/sha256"......
  • Centos7 yum 安装mysql8.0
    1.去mysql官网下载yum存储库包https://dev.mysql.com/downloads/repo/yum/  这里本人很早之前就下载过,就不重复下载了 2.安装mysqlyum......
  • MySQL8.0新特性—生成列
    生成列(generatedcolumn)的值是根据列定义中包含的表达式计算得出的。生成列包含下面两种类型:virtual(虚拟):当从表中读取记录时,将动态计算该列。stored(存储):当向表中写入新......
  • 阿里云服务(centos8)安装mysql8.0
    注意不同版本间的安装方式不太一样②如果出现:Error:GPGcheckFAILED这是gpg验证不通过的原因,因为我是在centos8系统上安装mysql57-community-release-el7-10.noarc......
  • MySQL8.0新特性—CTE
    MySQL8支持公用表表达式,包括非递归和递归两种。公用表表达式允许使用命名的临时结果集,这是通过允许在SELECT语句和某些其他语句前面使用WITH子句来实现的。不能在同一查......