title: Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
body: <p>When i connect my database by a php script it shows</p>
  
  <pre class="lang-none prettyprint-override"><code>Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
  </code></pre>
  
  <p>the username and password is right. </p>
  
  <p>something of the <code>my.cnf</code></p>
  
  <pre class="lang-none prettyprint-override"><code>[client]
  #password       = your_password
  port            = 3306
  socket          = /data/mysql/mysql.sock
  
  # Here follows entries for some specific programs
  
  # The MySQL server
  [mysqld]
  port            = 3306
  socket          = /data/mysql/mysql.sock
  skip-external-locking
  </code></pre>
  
  <p>ps: i change it to <code>socket = /var/lib/mysql/mysql.sock</code>  the php script  still says "/var/lib/mysql/mysql.sock"?. then run </p>
  
  <pre><code>  mysqladmin -u root -p status
  </code></pre>
  
  <p>it shows </p>
  
  <pre><code>mysqladmin: connect to server at 'localhost' failed
  error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
  Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
  
  
  
  
  service mysqld restart
  
  
  mysqld: unrecognized service
  </code></pre>