首页 > 解决方案 > Laravel 5.7 迁移错误:SQLSTATE[HY000] [2002] No such file or directory

问题描述

我正在为 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 项之外,这在两个站点的配置之前是相同的。

我不明白为什么会出错。

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

标签: laravelhomesteadmigrate

解决方案


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

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


推荐阅读