首页 > 解决方案 > mysql认证

问题描述

我无法让我的数据库在 wamp 中连接。自从我这样做以来已经大约 5 年了,所以我有点生疏了。我将我的 Mysql 升级到 8.0,我遇到了错误

 Fatal error: Uncaught PDOException: PDO::__construct(): The server requested authentication method unknown to the client [sha256_password] in C:\wamp64\www\dirtyosrs\assets\lib\core\Database.class.php:34 Stack trace: #0 C:\wamp64\www\dirtyosrs\assets\lib\core\Database.class.php(34): PDO->__construct('mysql:host=;dbn...', NULL, NULL, Array) #1 C:\wamp64\www\dirtyosrs\assets\lib\init.php(34): Database->connect() #2 C:\wamp64\www\dirtyosrs\templates\header.php(8): require_once('C:\\wamp64\\www\\d...') #3 C:\wamp64\www\dirtyosrs\index.php(1): include('C:\\wamp64\\www\\d...') #4 {main} Next PDOException: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client in C:\wamp64\www\dirtyosrs\assets\lib\core\Database.class.php on line 34

PDOException: PDO::__construct(): The server requested authentication method unknown to the client [sha256_password] in C:\wamp64\www\dirtyosrs\assets\lib\core\Database.class.php on line 34

我刷新了我的权限并将插件更改为根上的本机。在这一点上我很难过。有人可以帮助我吗?

这是我的数据库类,直到第 37 行

<?php

/**

标签: mysqlwampsha256

解决方案


自 2018 年以来,Mysql 8 具有一种新的默认类型的安全身份验证方法 (sha2),很难在 localhost 上工作。为了继续使用传统的 auth 方法,我在我的 Dockerfile 中这样做:

command: --default-authentication-plugin=mysql_native_password

如果您手动设置,则必须在数据库设置中运行 default-authentication 命令。

更多信息在这里:https ://mysqlserverteam.com/upgrading-to-mysql-8-0-default-authentication-plugin-considerations/


推荐阅读