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

    报的错误:

    In Connection.php line 664:
    
      SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = move and table_name = migrations and table_type = 'BASE TABLE')
    
    
    In PDOConnection.php line 31:
    
      SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
    
    
    In PDOConnection.php line 27:
    
      SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
    
    
    In PDOConnection.php line 27:
    
      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

    select user,host,plugin from mysql.user;

       

    我这里执行了两句修改,修改root身份的“localhost”和“%”,代码如下:

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

      

    执行成功:

  • 相关阅读:
    实现 AD 采样,使用 LCD1602 显示 AD 数值
    数据结构(C语言)—排序
    Keil uVision4 创建51单片机工程
    51单片机 方波
    51单片机串口中断实验
    51单片机 中断控制蜂鸣器
    串口通信
    定时器与计数器
    中断系统
    《web前端设计基础——HTML5、CSS3、JavaScript》 张树明版 简答题简单整理
  • 原文地址:https://www.cnblogs.com/hardykay/p/12092031.html
Copyright © 2011-2022 走看看