title: How to set PDO default host?
body: <p>I'm trying to convert some PHP code from Mysqli to PDO, and I need to be able to set a default host for PDO MySQL connections (outside of my application code).</p>
  
  <p>With Mysqli, I could do this with the <code>php.ini</code> setting:</p>
  
  <pre><code>mysqli.default_host = ip.of.mysql.server
  </code></pre>
  
  <p>And then connect with:</p>
  
  <pre><code>$link = mysqli_connect(null,  USERNAME,  PASSWORD, DATABASE);
  </code></pre>
  
  <p>It's worked beautifully for us.</p>
  
  <hr>
  
  <p>The equivalent code for PDO:</p>
  
  <pre><code>$link = new PDO('mysql:dbname=' . DATABASE, USERNAME, PASSWORD);
  </code></pre>
  
  <p>Doesn't work the same way.  It works as long as my MySQL server is on localhost.  It isn't. I have a separate machine hosting my MySQL server.</p>
  
  <p>Is there an equivalent <code>php.ini</code> setting that could accomplish what I need for PDO? The closest thing I've found is a <a href="http://www.php.net/manual/en/ref.pdo-mysql.php#ini.pdo-mysql.default-socket" rel="nofollow">pdo_mysql.default_socket</a> setting, but I don't think that will do it.</p>