In short the error means that mysql isn’t running. So the next reason is, why?
Recently I upgraded from php4 to php5 on one of my servers. Ever since then any time mysql does a restart I was getting this connection error. When the job went to restart it was failing and I’d be stuck going in and starting it myself. Sooo, the way to fix it is to open your etc/my.conf file and comment out basedir=/var/lib.