title: Can't connect to mysql using Bitnami lamp stack through php
body: <p>Ok, this will be a long question.</p>
  
  <p>I'm trying to get something up and running on my university account. We have a public_html folder that we can use as web space to host anything we want there. </p>
  
  <p>I've installed Bitnami lamp stack in the public_html folder (probably not the best idea, security-wise, but I'm only going to test this application for a couple of days and pull it down so I really don't care so long I can get this up and running fast) and the site I want to host is working fine and accessible via (http:// (uni address)/(my account name)/public_html/lamp/apache2/htdocs/(etc..). However, certain parts of the code that connects to the databse gives me the following warning:</p>
  
  <pre><code>Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  </code></pre>
  
  <p>I'm connecting to the database using the following code:</p>
  
  <pre><code>mysql_connect($CFG-&gt;dbhost,$CFG-&gt;dbuser,$CFG-&gt;dbpass);
  </code></pre>
  
  <p>Where dbhost is 'localhost'. </p>
  
  <p>Since it's referencing /var/run/mysqld/mysqld.sock  - it obviously means it's trying to connect to the wrong thing as the mysql in the lamp stack I've installed have the following in its my.cnf:</p>
  
  <pre><code>[mysqladmin]
  user=root
  
  [mysqld]
  basedir=(my account folder)/public_html/lamp/mysql
  datadir=(my account folder)/public_html/lamp/mysql/data
  port=3306
  socket=(my account folder)/public_html/lamp/mysql/tmp/mysql.sock
  tmpdir=(my account folder)/public_html/lamp/mysql/tmp
  
  [mysqld_safe]
  mysqld=mysqld.bin
  
  [client]
  port=3306
  socket=(my account folder)/public_html/lamp/mysql/tmp/mysql.sock
  
  [manager]
  port=3306
  socket=(my account folder)/public_html/lamp/mysql/tmp/mysql.sock
  pid-file=(my account folder)/public_html/lamp/mysql/tmp/manager.pid
  default-mysqld-path=(my account folder)/public_html/lamp/mysql/bin/mysqld.bin
  </code></pre>
  
  <p>So my question is, anyone know how to get it to connect to the correct socket? Also, var/run/mysqld/mysqld.sock doesn't exist at all and I obviously don't have the permission to create it (not that I see how it serves my purpose at all). </p>
  
  <p>This had been plaguing me since yesterday. Any help would be greatly appreciated.</p>
  
  <p>Cheers!</p>