PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 14, 2022

[FIXED] I have an error when trying to migrate Laravel database

 January 14, 2022     database, laravel, migration, php, phpmyadmin     No comments   

Issue

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?


Solution

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



Answered By - matthausen
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing