简体   繁体   中英

My database connection doesn't work in laravel. I can connect through CLI but not in the webapp

in CLI mysql works fine and i can connect to Database, but when i try a DB::connection()->getPDO() it goes to catch and says the following:

"SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client"

in CLI when i type SHOW TABLES; it does dump

mysql> SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| clients        |
+----------------+
1 row in set (0,00 sec)

mysql> 

I am using Mysql locally using brew services start mysql. I am a beginner when it comes to laravel and php development, this is school assignment.

I found my mistake. In tableplus I had to run the query:

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

I found this on another stackoverflow question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM