Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when execute php artisan migrate in laravel console

Tags:

php

laravel

When I try to execute php artisan migrate, I get the following:

In Connection.php line 647: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = cotacao_job and table_name = migrations)

APP_NAME=Laravel APP_ENV=local APP_KEY=base64:Ciz4TWDongGPodaNDo9wcxJh48A/af6JwWWE3/ydPkI= APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost/work-cotation-service/

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=33060 // I`ve tried 3360 too DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret

BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file SESSION_LIFETIME=120 QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379

MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null

its in a new homestead 5.1

like image 867
user536638 Avatar asked Aug 13 '26 11:08

user536638


2 Answers

When you are using homestead than you need to run these command in a vagrant box after ssh, not in the normal console to simply just follow these steps.

 1. ssh into your homestead using below command 
 2. cd ~homestead (where you set up your virtual box)
 3. vagrant up
 4. vagrant ssh
 5. cd Code/PATH_TO_YOUR_APP_ROOT_DIR
 6. php artisan migrate
like image 93
Vikas Rinvi Avatar answered Aug 16 '26 21:08

Vikas Rinvi


Configure the connection to the database in the .env file or config/database.php if you don't use .env

like image 32
Ilya Yaremchuk Avatar answered Aug 16 '26 19:08

Ilya Yaremchuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!