PHP trying to connect to local mysql database instead of specified remote address
<p>I am trying to connect to a remote MySQL database. The MySQL user has access from any IP address. I have root privileges on the Centos 6.8 VM that I am trying to connect from.</p>

<p>Yes I have googled this issue and so far nothing has worked. I am new to PHP so it is possible it is something simple. The path it is referring to '/var/lib/mysql/mysql.sock' does not exist but I feel like it shouldn't be looking for this socket because the DB is not on localhost. I have also double checked that my MySQL user has permission.</p>

<p>My code: index.php</p>

<pre><code>&lt;html&gt;
 &lt;head&gt;
  &lt;title&gt;PHP Test&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;?php 
   $user="myUsername";
   $password="myPW";
   $database="myDB";
   mysql_connect('xxx.x.xx.xx:xxxx',$user,$password);
   @mysql_select_db($database) or die( mysql_error());
   $query="SELECT * from myTable";
   mysql_query($query);
   mysql_close();
  ?&gt;
 &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The error I get printed on the page:</p>

<blockquote>
  <p>Can't connect to local MySQL server through socket
  '/var/lib/mysql/mysql.sock' (2)</p>
</blockquote>

<p>The error I get in the httpd/logs/error_log:</p>

<blockquote>
  <p>[Fri Jul 08 06:26:54 2016] [error] [client xxx.x.x.xxx] PHP Warning: 
  mysql_connect(): Can't connect to MySQL server on 'xxx.x.xx.xx' (13)
  in /var/www/html/index.php on line 10</p>
</blockquote>