問題描述
我使用 docker 并且我有一個 Laravel Framework 5.5.25 容器和其他帶有 mysql Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL) 的容器.在我的 docker compose 配置中,我有這個:
I using docker and I have a container of Laravel Framework 5.5.25 and other with mysql Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL). in my configuration of docker compose I have this:
version: "2"
services:
mysql:
image: mysql
ports:
- "3307:3306"
command: --sql_mode=""
所以,當(dāng) Laravel 嘗試連接到 MySql 時,我有這個錯誤:
So, when Laravel try to connect to MySql I have this error:
SQLSTATE[HY000] [2054] 服務(wù)器請求客戶端未知的身份驗證方法(SQL:select * from
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from
推薦答案
對于 MySQL 8 和 PHP7+,您必須使用舊式密碼:
You have to use legacy style passwords for MySQL 8 and PHP7+:
ALTER USER 'username'@'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
這篇關(guān)于如何解決錯誤:Laravel-MySql 中的 SQL 身份驗證方法未知的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!