Laravel 8: Solve the problem of php artisan migrate not working
P粉885035114
P粉885035114 2024-03-30 17:41:04
0
1
319

Everything was fine until I changed computers. I'm trying to migrate my database using php artisan migrate but I'm getting this error

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

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

      +33 vendor frames 
  34  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Any attempt to interact with the database gives me the same error

This is my .env configuration

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

P粉885035114
P粉885035114

reply all(1)
P粉794851975

The problem is because on my old computer I was using MAMP and now I'm using XAMPP, so the unix_socket path is wrong in the database.php file.

So go to the my.cnf file and search for the socket path, then make sure that socket path matches the database. in the unix_socket file The path is the same

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!