SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename or servname provided, or not known

2022-01-23 00:00:00 migration php mysql laravel laravel-5

我在运行 php artisan migrate

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename or servname provided, or not known

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

我的环境

  • Laravel 框架版本 5.1.20 (LTS)
  • Laravel 安装程序版本 1.2.0
  • PHP 5.6.14 (cli)(构建时间:2015 年 10 月 2 日 08:55:56)
  • mysql Ver 14.14 Distrib 5.6.24,适用于 osx10.10 (x86_64)

.env 文件

APP_ENV=local
APP_URL=http://localhost/
APP_DEBUG=true
APP_KEY=****

DB_HOST=http://localhost/
DB_DATABASE=name-local
DB_USERNAME=root
DB_PASSWORD=
UNIX_SOCKET = /tmp/mysql.sock

<小时>

该数据库 name-local 存在于我的本地数据库中.


That data-base name-local is exist in my local database.

任何提示/建议都会对我有很大帮助.

Any hints / suggestions will be a huge help for me.

推荐答案

检查 .env 文件中的 DB_HOST

DB_HOST=http://localhost/ --> DB_HOST=localhost

结果:

我现在可以和平迁移了.

I can migrate peacefully now.

php artisan migrate
Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table

相关文章