Back

Artisan error on migrate using Vagrant


Hi there,

I'm not sure if that is the right place for this kind of question.

I'm trying to switch from MAMP to Vagrant, wich I think is a good choice. I've setup Vagrant with an bootstrap.sh file

All work fine so far. I even can connect via Sequel Pro to MySQL and DB queries are working too. BUT, if I want to use "php artisan migrate", the following error comes up:

[PDOException]
  SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

So, I used 127.0.0.1 instead of localhost in database.php to solve the problem but this gives me an error too, like "Can't connect to 127.0.0.1". I insert an portforwarding into the Vagrantfile. But the problem still exists.

I think it is because I used MAMP before an I think I've changed something in the past to get Laravel run with MAMP, but I can't remember what I've changed.

XoneFobic replied 5 years ago Solution

Do you do the php artisan migrate on your local machine or the vagrant-box?


ssh into the vagrant box. Don't think you can run php artisan from the local machine if you need to reach the vm

foo41 replied 5 years ago

OMG you're damn right! I watched Jeffrey's Video on how to use Vagrant with Laravel on laracasts.com again. And what I've not seen in the first round was, that he used artisan in the Vagrant box. For me that means, looking all the vids twice!!! Thanks a lot for pointing me on this!

xuamox replied 4 years ago

I too just switched to Vagrant, and love what I see so far. It's a smoother process than using MAMP,and I love how you can just start or destroy your virtual server - awesome concept.

I too was confused about where to run migrate commands, but it makes perfect sense to do this inside of the virtual server.

I ssh into my vagrant server, but now I am confused.

Do i run the php artisan migrate of the the ssh command line, or do I need to navigate to a directory.

my Laravel project is at /laravel/public

Right now when I try and run the migrate command to create my db (via SSH on vagrant server) I get the following errors:

[email protected]:~$ php artisan migrate:make create_music
Could not open input file: artisan
arvidbjorkstrom replied 4 years ago

You need to cd to the right directory before running artisan.

vagrant ssh
cd /var/www/
php artisan migrate:make create_music
davhs replied 4 years ago

XoneFobic said:

Do you do the php artisan migrate on your local machine or the vagrant-box?


ssh into the vagrant box. Don't think you can run php artisan from the local machine if you need to reach the vm

I have a problem on the local machine. how do I fix this?


Sign in to participate in this thread!



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