托管MySQL连接

I am using this script to connect to a database. But it is throwing me this exception. Need Help!

<?php
$servername = "xxxx";
$username = "xxxx";
$password = "xxxx";

try {
    $conn = new PDO("mysql:host=$servername;dbname=my_db", $username, $password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully"; 
    }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }
?>

The exception :

Warning: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\Sites\mysql\index.php on line 8
Connection failed: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known.