1

This question has already been asked multiple times, however I can't seem to get it to work anyway.

I am trying to migrate a migration I just created with laravel to my freshly created database. However, everytime I type in php artisan migrate I'm getting the above error

PDOException SQLSTATE[HY000] [2002] No such file or directory

What I have done is the following:

Create a database and a database user

CREATE DATABASE openletter CHARACTER SET utf8;
CREATE USER 'openletter'@'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON openletter.* TO 'openletter'@'%';

Add these configs to the .env

DB_HOST=localhost
DB_DATABASE=openletter
DB_USERNAME=openletter
DB_PASSWORD=secret

Creating the migration

php artisan make:migration create_letters_table --create=letters

Migrating the migration

php artisan migrate

Then, the above listed error came.

What I tried

Restart the MySQL Service: vagrant ssh && sudo service mysqld restart
Reloading Homestead/Vagrant: vagrant reload --provision
Setting the database config in config/database.php

Many people telling others to link the mysql socket, but those people are refferencing MAMP or XAMPP or sth. else. I'm however using Homestead

What could also be the problem?

Musterknabe
  • 5,763
  • 14
  • 61
  • 117

1 Answers1

2

Ok guys, I fixed the issue. I'm an idiot and should be ashamed. The reason it didn't work, was because I wasn't in my vagrant machine.

After doing vagrant ssh navigating to my project cd work/OpenLetter and doing php artisan migrate it worked of course.

Musterknabe
  • 5,763
  • 14
  • 61
  • 117
  • Of course! Honest mistake. For me, getting the environment ready involves `source ~/.zshrc` then `homestead up --provision` then `homestead ssh`, of course making sure we are in the right dir. – Marcel Gruber Nov 13 '16 at 18:01