3

I have installed homestead on my machine and cloned a project from a remote repository, now I am trying to create a DB for my project. This is how my .env file looks like:

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:e7K7SUDgogNqTtP9TO1CfpbXFAC6FmLLSJ1l6K8pbWs=

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379

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

I have tried to connect to DB using sequel pro standard option:

Host: localhost
Password: secret

But I get:

Unable to connect to host 127.0.0.1, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Can't connect to MySQL server on '127.0.0.1' (61)

What am I doing wrong?

Leff
  • 1,968
  • 24
  • 97
  • 201
  • Did you set database connection properly? `DB_CONNECTION=mysql`. I don't see it in your .env file. – Martin Jun 19 '17 at 12:28
  • yes add your DB_CONNECTION and try this also DB_HOST=127.0.0.1 – molagbal Jun 19 '17 at 12:41
  • If you are using Mysql 8, I have answered this question here. https://stackoverflow.com/questions/51920183/connecting-to-sequel-pro-with-homestead-issues/64156476#64156476 – Davide Casiraghi Oct 01 '20 at 13:35

4 Answers4

0

Some options:

  • Check the service of mysql is running;
  • Check the user and passowrd are correct;
  • Check the privilege of the user, try root user
wbail
  • 536
  • 1
  • 7
  • 18
0

For Mysql Connection you should have check username and password. and .env file

DB_HOST=localhost
DB_DATABASE=Your Database name
DB_USERNAME=username 
DB_PASSWORD=password

Along With that, you can update database.php file for database configurations.

Hardika Satasiya
  • 354
  • 2
  • 3
  • 17
0

I had to add the port 33060 to be able to connect. Hope that will help others who got stuck like me.

Leff
  • 1,968
  • 24
  • 97
  • 201
0

I have some problem with Laravel 7 Homestead. I solve the error with this step:

  1. Use mysql port 33060
  2. Clear laraver config. php artisan config:clear
  3. Reload vagrant vagrant reload --provision

And make sure your database name and password is correct.

Happy coding.

Sukma Saputra
  • 1,539
  • 17
  • 32