MySQL error 2002 / Database error: connection failed!
I host a roundcube installation as well as YOURLS, which both make use of MySQL databases. Everything worked very fine, up until yesterday evening; MySQL decided it was time to make a mess of things and refused to work! Since I host two of my websites on the same VPS, using the same MySQL installation, they both stopped working at once.
The errors I get on my websites are as follows:
DATABASE ERROR: CONNECTION FAILED! Unable to connect to database.
SQLSTATE[HY000]  Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
The YOURLS error gave more insight into my problem, so I googled MySQL socket error and got a few interesting suggestions. On Stack Overflow, they suggested to chmod 777 the mysql socket, add
socket=/var/lib/mysql/mysql.sock to my.cnf, but none of this helps. However, one peculiarity I found is that MySQL starts working again after I restart it. Hmm, very strange. I'll try and reinstall it, after all, and see what comes of it.
Please help, if you know how to solve this problem. Thank you!