title: "Can't connect to local MySQL server through socket" on linux server
body: <p>I'm having a hard time getting my website connected to the mySQL database on host. However, when I was running my website on the PC by Apache it was connecting smoothly. The snippet I'm using to connect is:         </p>
  
  <pre><code>&lt;?php
      $conn_error = 'Could not connect';
  
      $mysql_host = 'localhost';
      $mysql_user = 'root';
      $mysql_pass = '';
  
      $mysql_db = 'firstdatabase';
  
      if(!mysql_connect($mysql_host,$mysql_user,$mysql_pass)|| !@mysql_select_db($mysql_db)){
          die($conn_error);
      }else{
          //echo 'Connected';
      }
  ?&gt;
  </code></pre>
  
  <p>And it gives me the following error when I try to connect to mysql on the web host:</p>
  
  <pre><code>Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server
  through socket 'MySQL' (2) in /home/umudo/public_html/connectserver.inc.php on line 10
  </code></pre>
  
  <p>I searched through the web for finding a solution but couldn't find any exact example of this.</p>