user2537792 user2537792 - 10 months ago 69
MySQL Question

Lumen error when using artisan migrate

I'm new to Lumen and when I try to use:

php artisan migrate

I get the following error.

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

If I change 'localhost' to '' I get this error:

SQLSTATE[HY000] [2002] Connection refused

If I use:

php artisan migrate --database=Lumen

I get:

Database [Lumen] not configured.

Here is my .env file


I've read other questions on stack overflow and have tried the solutions i.e. configuring php versions and checking the path to mysql.sock and it's all fine. I am using the full path and my PHP version is correct.

I am using MAMP and have a Database called 'Lumen' (there are no tables at the moment).

Created a migration using terminal:

php artisan make:migration --create=items create_items_table

I am using php artisan serve (server 8000) to view my project, which I can view.

MAMP is on:

I used the same configuration for my Laravel project and that is working fine. But laravel does have a database.php file which has all the details inside of it.

I hope that's enough information, any help would be much appreciated!

Thanks in advance

EDIT: This is my app.php file, the rest is left untouched.

require_once __DIR__.'/../vendor/autoload.php';


$app = new Laravel\Lumen\Application(


Answer Source

After a lot of fiddling about, I found the answer.

The problem was with MAMP, the pdo socket for mysql was not in the php.ini file and had to be included there.

; If mysqlnd is used: Number of cache slots for the internal result set cache
pdo_mysql.cache_size = 2000

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.

Including that line fixed all my probelems.