我有麻烦让我的数据库连接到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
/**
>
class Database*/class Database{
专用$IP、$username、$password、$database;
/**
/**
/**
自2018年以来,MySQL8有了一种新的默认类型的安全身份验证方法(sha2),这可能很难在本地主机上使用。为了继续使用传统的身份验证方法,我在我的DockerFile中是这样做的:
命令:--default-authentication-plugin=mysql_native_password
如果手动设置,则必须在数据库设置上运行default-authentication命令。
更多信息请访问:https://mysqlserveteram.com/upgrading-to-mysql-8-0-default-authentication-plugin-considentions/