Laravel - 解决连接MySQL时报"The server requested authentication method unknown to the client”错误
1,问题描述
Previous exceptions
- SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (2054)
- PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] (0)
2,问题原因
3,解决办法
4,操作步骤
|
1
|
sudo vi /etc/my.cnf |
(2)按下 i 进入编辑模式,添加如下内容(把加密模式改成旧的):
|
1
2
|
[mysqld]default_authentication_plugin=mysql_native_password |
(3)最后按下 esc 退出编辑模式。 接着组合按下 shift + : 开启命令,然后输入 wq 回车,保存退出。
|
1
|
mysql -u root -p |
(5)登录后依次执行下面三个命令(其中密码部分根据情况自行修改):
|
1
2
3
|
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';FLUSH PRIVILEGES; |
(6)完毕后重启 MySQL 服务可以发现,PHP 这边已经可以成功连接数据库了。
原文出自:www.hangge.com 转载请保留原文链接:https://www.hangge.com/blog/cache/detail_2331.html
Laravel - 解决连接MySQL时报"The server requested authentication method unknown to the client”错误的更多相关文章
- mysql 8.0 错误The server requested authentication method unknown to the client
mysql 安装了最新版本8.0.11后创建用户并授权后,授权的用户连接数据库提示 The server requested authentication method unknown to the ...
- php7.3连接MySQL8.0报错 PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]
报的错误: In Connection.php line : SQLSTATE[HY000] [] The server requested authentication method unknown ...
- PHP错误:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
使用PHP连接MySQL 8的时候,可能会发生如标题所示的错误: SQLSTATE[HY000] [2054] The server requested authentication method u ...
- mysql8.0:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
忽然注意到的情况: 2018/7/19至2018/9/13之间发布的7.1.20.7.1.21.7.1.22和7.2.8.7.2.9.7.2.10这六个版本提供的对caching_sha2_passw ...
- Docker mysql 连接 “The server requested authentication method unknown to the clien”错误
查了下,出现这个错误的原因是从mysql 5.6开始,mysql密码加密算法更改了. 我装的mysql 8.* ,那么有两种解决方法: mysql 版本选择 <= 5.6 修改密码 docker ...
- Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password]报错解决方法
错误: 解决方法:
- PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /usr/local/php/CreateDB.php on line 5
原因:php还不支持mysql8.0最新的密码加密方式 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ' ...
- PHP连接mysql8.0出错“SQLSTATE[HY000] [2054] The server requested authentication method unkno…
今天安装安装一个叫得推校园O2O系统的使劲都说连接不上服务器. 下面是安装说明,我直接进行3步骤,导入数据库配置文件,结果就显示题目报错的内容 安装说明: 直接输入程序目录即可 http://loca ...
- 使用navicat连接mysql时报错:2059 - authentication plugin 'caching_sha2_password'
首先从本地登录mysql数据库,进入mysql控制台,输入如下命令: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_passwo ...
随机推荐
- 剑指offer55:链表中环的入口结点
1 题目描述 给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null. 2 思路和方法 这是一个典型的链表中查找环的问题,基本思路是,首先设置两个快慢指针slow和fast,并且快指 ...
- springboot2.x配置druid sql监控
后端接口响应慢,通常我们就需要优化代码和sql,如果项目中使用druid连接池,那么我们可以利用其提供的sql监控功能,来帮助我们快速定位慢sql已经sql执行次数等问题,springboot2之后, ...
- VMWare安装Ubuntu16.04
一 概述 VMware Workstation 12的安装(略过,自行百度) Ubuntu16.04的安装 克隆出多个镜像 二 Ubuntu16.04的安装 1 准备 Window10 专业版(关闭H ...
- Go 编译 && 工具
编译和工具链 Go 的工具链非常丰富,从获取源码.编译.文档.测试.性能分析,到源码格式化.源码提示.重构工具等应有尽有 在 Go 中可以使用测试框架编写单元测试,使用统一的命令行即可测试及输出测试报 ...
- 如何理解H264 编码
H264 结构 https://blog.csdn.net/andywang201001/article/details/80274886 H264 源码 https://www.cnblogs.c ...
- echarts字体适配
var html = document.getElementsByTagName("html")[0]; var width = html.clientWidth; var too ...
- 只需五分钟-用Maven快速搭建Spring Cloud微服务
Maven安装手册 1.准备安装包 安装包: apache-maven-3.5.4-bin.zip (最好JDK 1.7及以上版本) 集成包: eclipse-maven3-plugin.zip 2 ...
- [dev][ipsec] 基于路由的VPrivateN
VPrivateN的配置分两个模式 1. 基于策略的VPrivateN ( policy based) 2. 基于路由的VPrivateN (route based) 以strongswan为例, 在 ...
- 软硬RAID 和 不常见的RAID
若转载请于明显处标明出处:http://www.cnblogs.com/kelamoyujuzhen/p/5561809.html 为啥子引入RAID? 存储最现实的两个问题:速度.容量 001——计 ...
- Go语言中的数据格式(json、xml 、msgpack、protobuf)
在分布式的系统中,因为涉及到数据的传输,所以一定会进行数据的交换,此时就要定义数据交换的格式,例如二进制.Json.Xml等等.本篇文章就是总结一下常用的几种数据格式. 一.Json格式 如果想使用J ...