Message: mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known

帅比萌擦擦* 提交于 2020-01-24 17:39:08

问题


I am new to PHP MVC CI and

I am getting below error.

Message: mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known.

Below is my info being passed.

hostname:http://localhost:1234/Sample/

username:root

password: //here Password is blank

database:codeignitordb

port:1234

Function

$mysqli->real_connect($hostname, 
                      $this->username, 
                      $this->password, 
                      $this->database, 
                      $port, 
                      $socket, 
                      $client_flags);

here $socket and $client_flags are Null

Question: Am I missing something ?


回答1:


Hostname should be localhost only instead of http://localhost:1234/Sample/

This change should be done in database.config.




回答2:


Try using 127.0.0.1

or

localhost

as your hostname



来源:https://stackoverflow.com/questions/33358703/message-mysqlireal-connect-php-network-getaddresses-getaddrinfo-failed-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!