Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0

Change 127.0.0.1 to localhost and it should work.

Last updated 2 years ago.
0

Thanks !

Last updated 2 years ago.
0

Thanks psychonetic

0

When migrating the DB i can only use: DB_HOST=127.0.0.1

When using the DB (from within the application) I have to switch this to: DB_HOST=localhost

How can I avoid this complication?

Last updated 9 years ago.
0

I had exactly the same problem, karlonauger.

If you're using Homestead, your DB_HOST should be set to localhost. The reason why in such case artisan (migrate) cannot connect to database is because you are not executing the commands inside your virtual machine.

To do it the right way connect to your vm using:

vagrant ssh

and once logged in, continue as you'd normally.

Hope that helps!

0

If you set the DB_HOST to the APP_URL then it will always work, on your dev machine and the VM so like this:

APP_URL=http://homestead.app

DB_CONNECTION=mysql
DB_HOST=homestead.app
DB_PORT=3306
DB_DATABASE=#
DB_USERNAME=homestead
DB_PASSWORD=secret
Last updated 8 years ago.
0

DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=sms DB_USERNAME=root DB_PASSWORD=root

work for me

0

@pshyconetic thank you very muuuch...

0

@psychonetic: thnaks you, good solution

0

Sign in to participate in this thread!

Eventy

Your banner here too?

SeLoRBIS selorbis Joined 7 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.