Mysql 8.0 error

when php7.3 , laravel5.7 , mysql8.0 is installed on centos7.5, the following error occurs when running php artisan migrate :

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

solution to Baidu:

Delete the created user and authorization, change it to the original authentication method, and then create the new user and authorize:

find the mysql profile and add:

default_authentication_plugin=mysql_native_password

or

mysql-uroot-p
use mysql;
ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY" your password";

problem:
Baidu"s solution is to go back to the previous verification method. What should I do if I want to use the new verification method?

Nov.01,2021

var_dump(phpinfo());

check whether there is auth_plugin_caching_sha2_password in Loaded plugins

my native version of PHP Version 7.2.10 can be connected directly. Try another version


it should be that php connects to the database using mysql_native_password authentication by default. Specify the caching_sha2_password authentication method in the php code to try

Menu