MySql Broke, and How I Fixed It
2010-11-03
After a couple of months of not needing to run MySql on my development machine, I suddenly had a need for it. Guess what? It wouldn't run. And it took a while to discover why.
After upgrading my home Ubuntu Linux box to 10.10, mysql stopped working. I was getting that awful message:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
Of course I googled the message, and read many of the million things people had written about it. I tried many of the solutions that had worked for others, none worked for me.
I finally came across references to apparmor and found this in the system logs:
apparmor="DENIED" operation="open" parent=2903 profile="/usr/sbin/mysqld" name="/sys/devices/system/cpu/" pid=3810 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Then I proceeded to spend two whole evenings playing with apparmor settings, enabling permissions, disabling it altogether, and nothing worked.
This evening I took the night off to catch up with some other work. Went to bed and couldn't sleep. Had the idea: I'll execute each line in /etc/init.d/mysql until something fails, then I'll understand what happened.
I finally got to the line that executes /usr/sbin/mysql_safe, and discovered I don't have that program. I tried to run it and got the helpful message that I could run apt-get to install it. I would just have to install the mysql server 5.1 package. That's funny - I've got mysqld and the client apps and so on. But anyway, I did run apt-get on that package and lo and behold - now it's back up and running again.
Lesson learned: If a service script can't start, try running each line, one by one, and find the one that fails.
Now I've got 4.5 hours to sleep before I have to drive my wife to the dentist, but I'll sleep well!