Laravel:SQLSTATE [HY000] [2054]服务器请求客户端未知的身份验证方法

问题描述:

在安装新的laravel应用5.7并尝试迁移后,出现此错误:

after installing a new laravel app 5.7 and trying to migrate I get this error:

Illuminate \ Database \ QueryException:SQLSTATE [HY000] [2054]服务器请求客户端未知的身份验证方法(SQL:从information_schema.tables中选择*,其中table_schema = xxx_db,table_name =迁移)

Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = xxx_db and table_name = migrations)

在 C:\ xampp \ htdocs \ xxxxx \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connection.php:664 660 |//如果在尝试运行查询时发生异常,我们将 格式化错误661 |//包含SQL绑定的消息, 这将使此异常成为662 |//对 开发人员,而不仅仅是数据库的错误. 663 |捕获(异常 $ e){

at C:\xampp\htdocs\xxxxx\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664 660| // If an exception occurs when attempting to run a query, we'll format the error 661| // message to include the bindings with SQL, which will make this exception a 662| // lot more helpful to the developer instead of just the database's errors. 663| catch (Exception $e) {

664 |抛出新的QueryException(665 | $ query, $ this-> prepareBindings($ bindings),$ e 666 | ); 667 | } 668 |

664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| } 668|

异常跟踪:

1 PDOException::(" PDO :: __ construct():服务器请求了 客户端未知的身份验证方法[caching_sha2_password]) C:\ xampp \ htdocs \ xxxxx \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connectors \ Connector.php:70

1 PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]") C:\xampp\htdocs\xxxxx\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

2 PDO :: __ construct("mysql:host = 127.0.0.1; port = 3306; dbname = xxx_db", 根", "**********", []) C:\ xampp \ htdocs \ xxxxx \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connectors \ Connector.php:70

2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=xxx_db ", "root", "**********", []) C:\xampp\htdocs\xxxxx\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

请使用参数-v查看更多详细信息.

Please use the argument -v to see more details.

此查询解决了我的问题.

This query solved my problem.

 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';