I was getting the following error with mysql and my rails app.
To fix it we just create a symlink.
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
That will fix it until you restart your system because the /tmp folder is temporary.
To create this link each time you restart, I add it to the end of my ~/.profile
# ~/.profile - Add this line to the end
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
Related External Links: