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_password

      mysql -uroot -p
      use mysql;
      ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘密码‘;
      FLUSH PRIVILEGES;
      
    • 以上修改完成以后,本地链接没有问题,但是远程连接还是不行,需要修改 host 为 %
      update user set host = ‘%‘ where user =‘root‘;
      
    • 假如上一步修改不成功,提示有重复数据 Duplicate entry ‘%-root‘ for key ‘user.PRIMARY‘,删除其他的信息
      delete user where user=‘root‘ and host =‘%‘;
      
  • 以上可以解决了已建账号的密码认证问题
  • 确保新添加的用户可以正常使用,需要把配置文件修改了
    • 配置文件:/etc/mysql/my.cnf
    • 解决办法:打开该文件,在 [mysqld] 模块下面添加一句 default_authentication_plugin=mysql_native_password

原文地址:https://www.cnblogs.com/liyiran/p/12573765.html

时间: 2024-08-27 12:05:25

SQLSTATE[HY000] [2054] 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.

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

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 a

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 变为原来的验证方式,然后从新创建用户并

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

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

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

[HY000] [2054] php连接mysql时错误

会出现这样的原因,主要都是因为mysql8.0版本的缘故,8.0版本默认编码为utf8mb4 解决方法: MySQL配置文件my.ini中[mysqld]下加这两行 character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci 然后又出现了另一个问题:The server requested authentication method unknown to the client 也是由于mysql版本缘故,8.0版本my

PHP连接MySQL报错:SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2)

如下所示,PHP连接MySQL报错: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2) 测试代码如下: <?php try { $dsn = 'mysql:dbname=php-note;host=localhost;port=3306;charset=utf8'; $username = 'root'; $password = 'root'; new PDO( $dsn,

MySQL 数据库连接失败 SQLSTATE[HY000] [2003] Can&#39;t connect to MySQL server on &#39;127.0.0.1&#39; (13)

CentOS6.5x64 安装禅道6.2,生成配置文件,数据库连接失败 数据库连接失败 SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (13) root,密码肯定没有错(命令行可以登录),用的127.0.0.1 PHP安装正常,MySQL配置正确,PHP的PDO.MySQL扩展正确,使用 <?php $link=mysql_connect('localhost','root','password'); if