在centos7.5上安裝了php7.3,laravel5.7,mysql8.0,運行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)百度到的解決辦法:刪除創建的用戶和授權,變為原來的驗證方式,然后從新創建用戶并授權即可:找到mysql配置文件并加入:default_authentication_plugin=mysql_native_password或mysql -uroot -puse mysql;ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密碼';問題:百度到的解決方式是退到以前的驗證方式,如果要使用新的驗證方式該怎么辦呢?
1 回答

慕勒3428872
TA貢獻1848條經驗 獲得超6個贊
應該是php連接數據庫是默認用mysql_native_password的認證方式,在php代碼里指定caching_sha2_password認證方式試試
添加回答
舉報
0/150
提交
取消