我正在使用php 7.2.2和mysql 8.0.
当我尝试连接正确的凭据时,我收到此错误:
PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]")
Run Code Online (Sandbox Code Playgroud)
需要帮助来解决问题.
Rei*_*eid 23
发现这个地方,不记得在哪里(或者我会相信),但它适用于我,直到MySQL 8变得更好.PHP已准备好用于MySQL的caching_sha2_password.
在MySQL shell中(命令提示符,无论如何):
CREATE USER username@localhost identified with mysql_native_password by 'password';
Run Code Online (Sandbox Code Playgroud)
其中username是用户名,密码是该用户的密码.
然后,您可以在shell中添加权限 - 或者在Workbench中添加权限,因为用户现在具有身份验证类型:标准.
Sze*_*obe 18
alter user 'username'@'localhost' identified with mysql_native_password by 'password';
Run Code Online (Sandbox Code Playgroud)
正如ailionx这里建议的那样:https : //github.com/laradock/laradock/issues/1390
为了使用 mySQL 8(使用新的身份验证方法),您只需升级 PHP。
MySQL 8
当运行 7.1.16 之前的 PHP 版本或 7.2.4 之前的 PHP 7.2 时,将 MySQL 8 Server 的默认密码插件设置为 mysql_native_password 否则您将看到类似于 The server requests authentication method unknown to the client [caching_sha2_password] 的错误,即使在 caching_sha2_password 时未使用。
参考:https : //www.php.net/manual/en/ref.pdo-mysql.php
| 归档时间: |
|
| 查看次数: |
25620 次 |
| 最近记录: |