Laravel 8:解决 php artisan migrate 不起作用的问题
P粉885035114
P粉885035114 2024-03-30 17:41:04
0
1
338

一切都很好,直到我换了电脑。我正在尝试使用 php artisan migrate 迁移我的数据库,但出现此错误

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

任何与数据库交互的尝试都会给我带来同样的错误

这是我的 .env 配置

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

P粉885035114
P粉885035114

全部回复(1)
P粉794851975

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

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!