I am new in Laravel development. I have updated Xampp to 7.3.11 on my Mac Mojave 10.14.6. In Laravel project when I hit php artisan migrate command I got following error.
<Try this conf in .env (i'm using Laravel v7.0), it's working for me :
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root
I had the same problem and when I applied the following operations, the problem was solved.
php artisan key:generate
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
Try out doing
php artisan config:cache
then on your .env file specify your database and your port
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= YOUR_DATABASE_NAME
DB_USERNAME=root
DB_PASSWORD=
then run your mysql server and run
php artisan migrate
Note: Make sure your Xammp server is perfectly fine & have already started mysql (using apache server or any server you are using) and also make sure you already created your database before running php artisan migrate Hope it works for you
In most cases it's an issue with the port configuration. You need to check which port your server is running on. Then you have to edit the .env file of your project. For instance if you are using mamp the port should be changed to 8889 instead of the default 3606 for laravel. The same applies to laravel 8.