PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known

前端 未结 2 798
抹茶落季
抹茶落季 2021-01-07 20:44

There are tons of questions asked on this topic on Stack Overflow, but none of them matches my case.

I am using Lampp with PHP 5.4.7 and it was running fine until I

相关标签:
2条回答
  • 2021-01-07 20:57

    Try using localhost ip instead: 127.0.0.1 and remove the quotes around dbname and host:

    $con=new PDO("mysql:host=127.0.0.1;dbname=data;charset=utf8",'root','');

    0 讨论(0)
  • 2021-01-07 21:16

    "mysql:host='localhost';dbname='data';charset=utf8"

    Your DSN format is wrong, it shouldn't have those quotes in there. This is the right format

     //$con=new PDO($dsn, $user, $password);
     $con=new PDO('mysql:dbname=testdb;host=127.0.0.1','root',''); 
    

    See Manual

    0 讨论(0)
提交回复
热议问题