title: How to connect live database from localhost(localmachine)
body: <p>I am trying to connect live database from my localhost. </p>
  
  <p>My code snippet is</p>
  
  <pre><code>$hostname="my ip address";
  $userName="my_user";
  $password="password";
  $database="test_db";
  $port="3306";
  
  $con2=mysqli_connect($hostname,$userName,$password,$database,$port);
  
   if ($con2-&gt;connect_error) {
   die("Connection failed: " . $con2-&gt;connect_error);
  }else{
  echo "&lt;br&gt; connection successfull----con2";
  }
  die;
  </code></pre>
  
  <p>I want to insert some data from my localhost to live database.</p>
  
  <p>when am trying to connect using the above code snippet its showing error message like</p>
  
  <blockquote>
    <p>"Warning: mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it. in D:\xampp\htdocs\migration\migration.php on line 12
    Connection failed: No connection could be made because the target machine actively refused it."</p>
  </blockquote>
  
  <p>Anybody could you please help me ?</p>
  
  <p>I want to establish database connection from my localmachine.</p>
  
  <p>Thanks.</p>