I'm working on a rather small project, and today I got an SQLSTATE[HY000][2002]:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' error. After a bit of googling and a few attempts to restart the mysqld service, I gave up and tried rebooting the computer. This did the trick, MySQL was now running fine.
I did, however, get a more serious issue: Some files were missing, others were altered. Also, a few posts in the MySQL was gone. It's really strange, it's like the whole project has been reset two or three days, and I have no clue why.
Some additional details about this:
I save my files after every line of code. I'm religious about this. So I haven't lost the files that way.
I was accessing the server via SSH when the error occurred, so I did the programming and the reboot over SSH.
The server is a Raspberry Pi, model B, with Raspian on which I run Apache2.
I was viewing the site and had an active session when I rebooted the system.
The pages I lost did work just before this all happened.
The MySQL fault occurred when I tried to add a text NOT NULL column to a table which had entries.
Now, the amount of lost work isn't really that much, so I'm not really looking for help recovering the files. The reason I'm posting this is because I wonder how did this happen, and why?