The server requested authentication method unknown to the client

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client.

In MySQL 8.0+, the default authentication plugin has changed from
‘mysql_native_password‘ to ‘caching_sha2_password‘, and the
‘root‘@‘localhost‘ administrative account uses the
‘caching_sha2_password‘ authentication plugin by default. If you prefer
that the root account use the previous default authentication plugin
‘mysql_native_password‘.

The PDO_MySQL and ext/mysqli extensions of PHP do not support
caching_sha2_password. In addition, when PHP MySQL extensions used with
PHP versions before 7.1.16 and PHP 7.2 before 7.2.4, they fail to
connect with default_authentication_plugin=caching_sha2_password even if
caching_sha2_password is not used. However the X DevAPI PHP extension
(mysql_xdevapi) supports it.

To restore MySQL pre-8.0 compatibility, you can reconfigure the server
to revert to the previous default authentication plugin
mysql_native_password like:

  1. [mysqld]
  2. default_authentication_plugin=mysql_native_password

复制代码

Restart
the MySQL database, the problem should be solved, otherwise you may
need to reinitialize the MySQL installation data and reinstall it.

You can connect to the MySQL database using mysql commandline utility,
and then create a new user with the older mysql_native_password plugin
with SQL.

  1. mysql -uroot -p
  1. CREATE USER ‘WUXIANCHENG‘ IDENTIFIED WITH ‘mysql_native_password‘ BY ‘YOUR_PASSWORD_IN_TRANSPARENT_TEXT‘;
  2. GRANT ALL PRIVILEGES ON *.* TO ‘WUXIANCHENG‘@‘%‘;

Now
you can connect to the MySQL database in PHP using the newly created
account. You can also change existing users‘ authentication plugin after
connecting to the MySQL database with the new account.

  1. use mysql;
  2. UPDATE `user` SET `Host`=‘%‘ WHERE `User`=‘root‘;
  3. ALTER USER ‘root‘ IDENTIFIED WITH ‘mysql_native_password‘ BY ‘YOUR_PASSWORD_IN_TRANSPARENT_TEXT‘;

If
the default root user was restricted to localhost, the ALTER USER
statment will fail with message like "ERROR 1396 (HY000): Operation
ALTER USER failed for ‘root‘@‘%‘", so you have to change Host from
localhost to % first.

Dont‘ forget to replace YOUR_PASSWORD_IN_TRANSPARENT_TEXT with your own password!

原文地址:https://www.cnblogs.com/jdcai/p/9202584.html

时间: 2024-11-05 23:25:28

The server requested authentication method unknown to the client的相关文章

PHP错误:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

使用PHP连接MySQL 8的时候,可能会发生如标题所示的错误: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client 发生这种错误,是由于MySQL 8默认使用了新的密码验证插件:caching_sha2_password,而之前的PHP版本中所带的mysqlnd无法支持这种验证.解决这个问题,有两种办法. 一种办法是升级PHP支持MySQL 8的新验证插件. PHP 7.

mysql 8.0 错误The server requested authentication method unknown to the client

mysql 安装了最新版本8.0.11后创建用户并授权后,授权的用户连接数据库提示 The server requested authentication method unknown to the client 查阅一些相关的资料后发现是由于新版本的mysql账号密码解锁机制不一致导致的 解决办法: 删除创建的用户和授权, 找到mysql配置文件并加入 default_authentication_plugin=mysql_native_password 变为原来的验证方式,然后从新创建用户并

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

安装 nextcloud 的时候选择的是 mysql ,在链接 mysql 的时候报错,信息如下: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client 搜索了下应该是 MySQL 8默认使用了新的密码验证插件:caching_sha2_password ,而有些 PHP 版本不支持这个问题造成的 解决办法: 修改登录用户的 plugin 为 mysql_native_pas

Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password]报错解决方法

错误: 解决方法: 原文地址:https://www.cnblogs.com/NuoChong/p/10013272.html

PHP连接mysql8.0出错“SQLSTATE[HY000] [2054] The server requested authentication method unknow.....

这个错可能是mysql默认使用 caching_sha2_password作为默认的身份验证插件,而不再是 mysql_native_password,但是客户端暂时不支持这个插件导致的. 解决方法一:修改MySQL全局配置文件 编辑 my.cnf文件,更改默认的身份认证插件. $ vi /etc/my.cnf 在 [mysqld]中添加下边的代码 default_authentication_plugin=mysql_native_password 然后重启mysql $ service my

PDO连接mysql8.0报PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers错误

安装mysql8.0之后,尝试使用php连接mysql,总是报PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers错误,网上找了很多资料,然而都没有多大用处. 查找了mysql官方说明文档才知道原来M8.0已经已经把默认字符集升级成ut8mb4了,于是找到my.cnf文件,修改如下: 1 [client] 2 port = 3306 3 socke

Network authentication method and device for implementing the same

A network authentication method is to be implemented using a network authentication device and a user end for authenticating the user end. The network authentication method includes the steps of: configuring the network authentication device to store

Authentication method 'caching_sha2_password' not supported by any of the available plugins.

这是MySQL8.0一个登录验证的问题. 第一步 初始化配置 如果已经初始化了,就直接跳过第一步 你需要知道的是:MySQL安装的路径.我的路径是:G:\mysql-8.0.11-winx64 在C:\Windows\System32路径下找到cmd.exe,右键以管理员身份运行,并切换到mysql-8.0.11-winx64中. 输入命令初始化data目录: mysqld --initialize --console 会出现一段内容,找到内容中root@localhost: 它后面就是登录数据

Authentication method 'caching_sha2_password' not supported by any of the av的解决方法

Authentication method 'caching_sha2_password' not supported by any of the av的意思是任何av都不支持身份验证方法“缓存密码” 通常的报这个错误是因为它的身份验证方式是  mysql_native_password 方式,不是caching_sha2_password方式 方法一 如果是通过解压去安装的MySQL 8.0版本 1.找一下看有没有my.ini文件 没有就在你解压密闭的目录下新创建一个my.ini文件 my.i