Mohamed  Kira
Mohamed Kira

Reputation: 417

seperate DB for each laravel/homestead project

I've come across so many posts about this problem but albeit am following all the solutions its still not working for me

this is my homestead.ymal

sites:
    - map: homestead.com
      to: /home/nanashi/public
    - map: boomer.com
      to: /home/boomer/public

databases:
    - homestead
    - boomer

my .env file

DB_CONNECTION=mysql
DB_HOST=192.168.10.10
DB_PORT=33060
DB_DATABASE=boomer
DB_USERNAME=root
DB_PASSWORD=

I have several migration and while I try to run it from the vagrant machine itself(after SSHing into it), it gives me an error of table already exists I want to connect to boomer DB (which is empty) and make migration there but the VM still connects to the DB names homestead(for another project)

I tried to provision the VM but still, nothing happens I've also changed the port to 3306*0*

Upvotes: 0

Views: 32

Answers (2)

Mohamed  Kira
Mohamed Kira

Reputation: 417

1-create the project on your physical machine

2-I pushed the project to github

3- i ssh into the VM, and created the DB from there.

4- changed the DB engine to InnoDB

5- git clone my project from github 6- i ran the migrations

I know my solution is not ideal, but these are the steps i followed to solve my problem for anyone out there got stuck on the same issue

Upvotes: 0

ndberg
ndberg

Reputation: 4001

Your .env should look like this:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=boomer
DB_USERNAME=homestead
DB_PASSWORD=secret

To run your artisan commands, you should first log into your vagrant machine with:

vagrant ssh

-> then go in to the project folder and then run your migration commands there

php artisan migrate

Upvotes: 1

Related Questions