3
votes

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

3

3 Answers

2
votes

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
1
votes

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

0
votes

I Think the problem occur just because you are not setting up the database detail in the .env file so kindly update it or else you can also configure it by update the details in config/database.php

For .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=root
DB_PASSWORD=