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 ...
随机推荐
- ubuntu 安装 Java 开发环境
可以使用命令 -jre-headless 或者使用: 本文链接:https://blog.csdn.net/sangewuxie/article/details/80958611 本人的ubunt ...
- Win自带mastc远程Cenots7桌面
1.Centos7安装桌面 yum -y groups install "GNOME Desktop" startx 2.安装xrdp 操作需要root用户权限,所以,我们先切换为 ...
- 怎样判断当前浏览器是PC浏览器还是手机浏览器
可以通过检测navigator.userAgent字段中是否有"mobi"字段来检测是PC浏览器还是手机浏览器: /mobi/i.test(window.navigator.use ...
- SringMVC笔记
SpringMvc主要是三个Servlet:HttpServletBean,FramwworkServlet,DispatcherServlet,它们是依次继承的关系,其处理过程大致功能如下: 1.H ...
- 解决SVN蓝色问号的问题
桌面或文件夹右键,选择TortoiseSVN->Settings打开设置对话框,选择Icon Overlays->Overlay Handlers->取消钩选Unversioned. ...
- GOF学习笔记1:术语
1.abstract class 抽象类定义了一个接口,把部分或全部实现留给了子类,不能实例化. 2.abstract coupling 抽象耦合如果一个类A引用了另一个抽象类B,那么就说A是抽象耦 ...
- Django_rest_framework分页
分页基本流程及配置 1.基于LimitOffsetPagination做分页,根据配置 from rest_framework.pagination import LimitOffsetPaginat ...
- iOS - Scenekit3D引擎初探之 - 导入模型+上传服务器+下载并简单设置
SceneKit是ios8之后苹果推出了一个3D模型渲染框架. SceneKit现在可以支持有限的几种模型,截止到我写这篇文章为止似乎只有.dae和.abc后一种模型我没有使用过.这篇文章只针对.da ...
- 采用localStorage做定时缓存
背景 页面采用ajax获取数据时,每访问一次就会发送一次请求向服务端获取数据,可是呢. 有些数据更新的又不频繁,所以我就想着使用localStorage进行本地存储,然后在固定间隔时在去更新数据.(下 ...
- Fortify漏洞之Cross-Site Scripting(XSS 跨站脚本攻击)
书接上文,继续对Fortify漏洞进行总结,本篇主要针对XSS跨站脚步攻击漏洞进行总结,如下: 1.Cross-Site Scripting(XSS 跨站脚本攻击) 1.1.产生原因: 1. 数据通过 ...