Skip to content
Advertisement

SQLSTATE[HY000] [2002] No such file or directory when i try to php artisan migrate

Just made a new laravel project and tried to migrate the tables and i got this :

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = sugarDaddy and table_name = migrations and table_type = ‘BASE TABLE’)

I tried clearing the cache, the routes, the config, and changing the DBHOST from 127.0.0.1 to localhost and back as i saw in a few articles on so, but nothing worked. i’ll leave here the migration and an ss to the database.

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sugarDaddy
DB_USERNAME=root
DB_PASSWORD=

the database ss

Advertisement

Answer

I can see from the screenshot that your phpMyAdmin is connecting to the database at 8889 port, your env has DB_PORT=3306, change to DB_PORT=8889.

Summary of the comment section:

Dan is using MAMP, so the config for mysql connection should contain (for default MAMP settings):

DB_HOST=localhost
DB_PORT=8889
DB_USERNAME=root
DB_PASSWORD=root
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement