zoukankan      html  css  js  c++  java
  • php7.4连接MySQL8.0报错 PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]")

    原因:
    mysql8默认的使用密码认证方式不一样,mysql8.0默认使用caching_sha2_password,但是之前版本都是使用mysql_native_password

    解决方案:
    将密码认证方式caching_sha2_password修改为mysql_native_password

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

    修改root身份的"localhost"

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

    如果有root身份的"%"也改一下

    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
    

    再次查看

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

      

  • 相关阅读:
    [UE4]创建对象的的几种姿势(C++)
    [UE4]IES光源概述文件
    [UE4]C++ STL总结
    [UE4]C++中引用(&)的用法和应用实例
    [UE4]单映射:TMap容器,字典表
    [UE4]集合:TSet容器
    [UE4]动态数组:TArray容器
    [UE4] 虚幻4学习---UE4中的字符串转换
    [UE4]使用PlayerController获取鼠标点击时的坐标
    [UE4]C 语言动态数组
  • 原文地址:https://www.cnblogs.com/Wtingting/p/14137458.html
Copyright © 2011-2022 走看看