【问题标题】:Laravel 5.7 migrate error : SQLSTATE[HY000] [2002] No such file or directoryLaravel 5.7 迁移错误:SQLSTATE[HY000] [2002] No such file or directory
【发布时间】:2019-07-24 18:03:10
【问题描述】:

我将宅基地用于 laravel。 我已经安装了 2 个虚拟网站。当我尝试迁移时,两个网站数据库运行良好。但是今天我创建了新网站并尝试迁移,我发现错误如下所示。

Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = test and table_name = migrations)


这是我的 .env 文件

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:2ZFx67Hrfao+ngk6hmyjDPmmXPiz4hXejJ5ncMqeX5E=
APP_DEBUG=true
APP_URL=http://test.app

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=test
DB_USERNAME=homestead
DB_PASSWORD=secret

这是 homestead.yaml 文件

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

ssl: true

folders:
    - map: ~/Dev/sites/test
      to: /home/vagrant/sites/test

    - map: ~/Dev/sites/cvms
      to: /home/vagrant/sites/cvms

    - map: ~/Dev/sites/poms
      to: /home/vagrant/sites/poms

sites:
    - map: test.app
      to: /home/vagrant/sites/test/public

    - map: cvms.app
      to: /home/vagrant/sites/cvms/public

    - map: poms.app
      to: /home/vagrant/sites/poms/public

databases:
    - test
    - cvms
    - poms

当然,除了 DB_DATEBASE 项之外,两个站点的配置之前都是一样的。

我不明白为什么会出错。

对不起,我糟糕的英语......

【问题讨论】:

标签: laravel homestead migrate


【解决方案1】:

尝试访问您的.env 文件。按照 phpadmin 的建议,检查所有数据库名称/信用凭证是否正确。

DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

【讨论】:

    【解决方案2】:

    尝试在虚拟机中运行php artisan migrate 命令。 通知Laravel's docs

    【讨论】:

      猜你喜欢
      • 2015-04-04
      • 1970-01-01
      • 2023-04-01
      • 2013-10-08
      • 2015-04-22
      • 1970-01-01
      • 2021-07-05
      • 2020-10-03
      • 2019-05-02
      相关资源
      最近更新 更多