skip to Main Content

I am new to Laravel. I have MAMP and Xampp 7.3.0 installed on my MacOS Mojave but currently using Xampp on port 80 with MySQL port reconfigured to 33060 as phpmyadmin wasn’t working.
I have a problem with “php artisan migrate” as the following error displays each time I am trying to migrate:

SQLSTATE[HY000] [2002] No such file or directory (SQL:

select * from information_schema.tables where table_schema = land
  on_app and table_name = migrations

)

I have tried to search online, adopted the suggested solutions by contributors but none seems to work for me. I have tried to install MySQL 8.0.13, but I encountered caching_sha2_password which prompted me to uninstall it and installed MySQL5.7 with a displayed version message “mysql Ver 14.14 Distrib 5.7.24, for osx10.14 (x86_64) using EditLine wrapper
However, I decided to copy the folder to httdoc and reconfigured my .env.

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=landon_app
DB_USERNAME=root
DB_PASSWORD=

database.php

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '33060'),
            'database' => env('DB_DATABASE', 'landon_app'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,


        ],

AppServiceProvider

<?php

namespace AppProviders;

use IlluminateSupportServiceProvider;
use IlluminateSupportFacadesSchema; //This must be added 


class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Schema::defaultStringLength(191); //This must be added to allow connection to the database
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

The error I receive each time I try to migrate:

3

Answers


  1. Just change this line in your .env file:

    DB_HOST=localhost
    

    To

    DB_HOST=127.0.0.1
    
    Login or Signup to reply.
  2. Start with few simple debugging steps:
    – Can you access your mysql server with provided credentials?
    – Can you verify that the database named ‘landon_app’ exist on ur server?
    – You can also try changing host from localhost to 127.0.0.1

    Login or Signup to reply.
  3. Laravel 4: Change “host” in the app/config/database.php file from “localhost” to “127.0.0.1”

    Laravel 5: Change “DB_HOST” in the .env file from “localhost” to “127.0.0.1”

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search