当前位置:首页 > PHP教程 >

php_network_getaddresses: getaddrinfo failed: Name or service not known

发布时间:2020-04-01 11:36:59 作者:佚名 阅读:(34)

今天安装一个Laravel的网站,配置好之后,执行数据库的创建命令,提示:hp_network_getaddresses: getaddrinfo failed: Name or service not known,接下来吾爱编程为大家介绍一下解决方法,有需要的小伙伴可以参考一下:

1、错误提示:

[[email protected] wizard]# php artisan migrate:install

In Connection.php line 664:                                                                                                                                                                                                                                                               
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (SQL: create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(191) not null, `batch` int not null) default character set utf  
  8mb4 collate 'utf8mb4_unicode_ci')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
In PDOConnection.php line 31:                                                                                    
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known                                                                           
In PDOConnection.php line 27:                                                                                      
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known  
In PDOConnection.php line 27:                                                                
  PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known

2、错误原因:

    产生上面错误的原因一般是由于数据库的链接有问题,看下配置文件写的是否正确

3、修改方法:

# 数据库连接配置
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=wizard
DB_USERNAME=root
DB_PASSWORD=123456

把数据库的DB_HOST改成localhost或者127.0.0.1,保存

4、验证:

[[email protected] wizard]# php artisan migrate:install
Migration table created successfully.

以上就是吾爱编程为大家介绍的关于php_network_getaddresses: getaddrinfo failed: Name or service not   known的解决方法,了解更多相关文章请关注吾爱编程网!

欢迎分享转载→ php_network_getaddresses: getaddrinfo failed: Name or service not known

© 2015-2019 - 吾爱编程网 版权所有 苏ICP备18033726号-1关于我们 - 网站声明 - 联系我们