Well its quite a complicated problem, life was smooth and easy on ubuntu, when suddenly after upgrade to mysql-server-5.5, the mysql failed to start.
As a background info I must tell that I am using Windows 7 and ubuntu 12.04 on a single machine (dual boot) from different harddisks, and for web development I use single folder as IIS webroot (windows 7) and apache2 www (ubuntu). Same goes for mysql, I have single directory share for both windows and ubuntu.
However, after the upgrade, things got wrong in ubuntu and mysql failed to start. I check all the logs for mysql and there was no error.
Then I checked the logs for apparmor, because after ubuntu 10.04, apparmor needs to be clarified about the data dir of mysql, which I had done earlier, but to no avail. Nothing was mentioned there.
System log and kernal logs just showed that mysql cannot start.
To resolve the problem what I did Remember: I have different data dir then the default so I didn’t backup that, which otherwise may look like
sudo cp /var/lib/mysql ~/mysql-data
Then purge the installations
sudo aptitude purge mysql-common mysql-server mysql-client
Then simply remove the remaining folders
sudo rm /etc/mysql -R
now reinstall mysql from the scratch.
sudo aptitude install mysql-common mysql-server mysql-client
After the complete installation and configuration, I tried to again set the apparmor to change mysql datadir, but this somehow is not working now.
So the alternate is to run the following command
sudo ln -s /your-mysql-data-dir/* /var/lib/mysql
This will create a soft link for each file in your existing datadir to the ubuntu(/debian linux’s) mysql datadir. This way it will share the same data.
However, this approach has a few limitations.
- This will only work if you use windows mainly and create new databases there only.
- For each new database You would have to run the last line again, I am looking for a way to attach this line as a script on mysql startup.
Hope this resolves the problem.