2017-04-26 195 views
-2

我試圖連接到遠程Rackspace公司DB PHP:獲取連接超時與DB連接

<?php 
    $servername = "XX.XX.XX.XX"; 
    $username = "username"; 
    $password = "password"; 
    $dbname = "table"; 
    // Create connection 
     $conn = new mysqli($servername, $username, $password, $dbname); 
    // Check connection 
     if ($conn->connect_error) { 
     die("Connection failed: " . $conn->connect_error); 
    } 
?> 

我也得到警告:mysqli的:: mysqli的()(HY000/2002):連接超時出 任何建議

+0

是MySQL服務器運行? – Jens

+0

是的,它正在運行 – Ron

+0

您是否嘗試過重新啓動? – Jens

回答

0

試試這個

<?php 
     $servername = "XX.XX.XX.XX"; 
     $username = "username"; 
     $password = "password"; 
     $dbname = "table"; 
     // Create connection 
      $conn = mysqli_connect($servername, $username, $password, $dbname); 
     // Check connection 
      if (mysqli_connect_errno()) { 
     echo "Failed to connect to MySQL: " . mysqli_connect_error();die(); 

     } 
    ?>