0
votes

I am an absolute beginner in Laravel (v 5.7.2) and I am facing my first real obstacle. On MAMP, after successfully creating a database via phpmyadmin and a model php artisan make:model [modelname] -m, when i try to migrate it php artisan migrate, I get the following error:

Exception trace:

1 PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]") /Applications/MAMP/htdocs/loginsystemLaravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68

2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=lsapp", "root", "", []) /Applications/MAMP/htdocs/loginsystemLaravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68

I double checked the files .env and database.php and they ALL have the same configurations.

What is happening?

2
could be because mysql version is not supported by laravel. Can u change the db authentication method? ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';Kimberlee Ho
What port is MySQL using in MAMP?Rwd
Looks like downvoting a question is the norm here... Thank yoiu guys for your answers. I am using default port 3306, connection type is socket, although I am not sure if I have to write something there. Also I tried both with HostName localhost and 127.0.0.1 without success...matthausen

2 Answers

0
votes

Finally solved it myself by coincidence. I realized I had both version of mysql installed, mysql8 and mysql57. The first one supports by default cachin sha2 which is not yet supported by laravel. Possible solutions:

1)Change default mysql login method. 2) Use 5.7. 3) Remember to set the same parameters in .env and config/database.php files.

Hope this will help someone else

0
votes

just look in the .env File what DB_Name Goto phpmyadmin and create a new Database ("Laravel") in my case