Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EroTiXx's avatar

Cannot running "php artisan: migrate"

Hello everyone,

I'm desperate to finish installing Spark.

I have an error when I write the command "php artisan: migrate". I have this error while my database exists and I can access it with another laravel project ...

It's been 2 hours I'm looking for no answer

Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = api-bbk and table_name = migrations)

  at /Users/amartineau/Documents/Sites/api-bbk/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("SQLSTATE[HY000] [2002] No such file or directory")
      /Users/amartineau/Documents/Sites/api-bbk/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68

  2   PDO::__construct("mysql:host=localhost;port=3306;dbname=api-bbk", "root", "root", [])
      /Users/amartineau/Documents/Sites/api-bbk/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68

And this is my .en file :

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=api-bbk
DB_USERNAME=root
DB_PASSWORD=root

Do you have any solution for this problem?

Thank you in advance

0 likes
6 replies
Snapey's avatar

if you have changed config, try running php artisan config:clear

EroTiXx's avatar

I tried all clear php artisan, no change :/

EroTiXx's avatar

I modify "api-bkk" to "api", same problem :'(

( Before i make config:clear etc... )

EroTiXx's avatar
EroTiXx
OP
Best Answer
Level 1

I found a solution.

As I'm on MAMP, I had to specify the socket

'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',

skliche's avatar

Does 127.0.0.1 instead of localhost work?

Something else to check: Is the PHP invoked on the command line the same as invoked by your web server? Maybe on the command line a different PHP is invoked and it's configuration points to the wrong mysql socket file.

Please or to participate in this conversation.