PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, December 28, 2021

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

 December 28, 2021     database-migration, laravel, mamp, php     No comments   

Issue

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 Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

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


Solution

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


Answered By - Adrian Kokot
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing