php7.3连接MySQL8.0报错 PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]
2024-09-02 06:21:15
报的错误:
In Connection.php line : SQLSTATE[HY000] [] 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 : SQLSTATE[HY000] [] The server requested authentication method unknown to the client In PDOConnection.php line : SQLSTATE[HY000] [] The server requested authentication method unknown to the client In PDOConnection.php line : 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';
执行成功:
最新文章
- typedef
- PHP while使用
- SSIS-包调用包错误的解决方案
- [LeetCode]题解(python):043-Multiply Strings
- POJ 1759
- Oracle V$SESSION详解
- linux系统管理
- index rang scan
- vmware-tools(vmware workstation 10.0.4)安装的时候遇到的bug
- OpenStack 部署总结之:在CentOS 6.5上使用RDO单机安装icehouse(Ml2+GRE)
- eclipse maven 打war包的几种方式
- javascript Json和String互转
- C# interface 的隐式与显示实现及适应范围源码演示
- PHP调用接口用post方法传送json数据
- 基于HTML5 Canvas 实现地铁站监控
- 01---JMS与消息中间件的基本概念
- 常见Chrome 插件
- MySql利用mysqldump导出/导入数据库表数据
- 概率p输出1,概率1-p输出0,等概率输出0和1
- 在windows下实时监控、接受文件变化小工具