Laravel 8: Lösen Sie das Problem, dass die PHP-Artisan-Migration nicht funktioniert
P粉885035114
P粉885035114 2024-03-30 17:41:04
0
1
317

Alles war in Ordnung, bis ich den Computer gewechselt habe. Ich versuche, meine Datenbank mit php artisan migrate zu migrieren, erhalte jedoch diese Fehlermeldung

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))

Jeder Versuch, mit der Datenbank zu interagieren, gibt mir den gleichen Fehler

Dies ist meine .env-Konfiguration

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

P粉885035114
P粉885035114

Antworte allen(1)
P粉794851975

问题是因为在我的旧电脑上我使用的是 MAMP,现在我使用的是 XAMPP,所以在 database.php 文件中 unix_socket 路径是错误的。

因此,转到 my.cnf 文件并搜索套接字路径,然后确保该套接字路径与 unix_socket 文件中的 database. 路径相同

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!