Thursday, July 19, 2012

Unable to start MySQL after upgrade to Ubuntu 12.04 LTS

I recently upgraded one of my Ubuntu servers from 10.04 LTS to 12.04 LTS. During the process it warned me about the servers MySQL configuration file being different then the one provided in the package by the maintainer. I selected to keep mine, with it’s customizations, however after the upgrade I was no longer able to start the MySQL service.

To get the list of MySQL packages that were installed and that I needed to remove, I used the following command:

dpkg –get-selections | grep mysql

I removed the MySQL server using the following command:

sudo apt-get remove libmysqlclient16 libmysqlclient18 mysql-client-core–5.5 mysql-common mysql-server–5.1 mysql-server–5.5 mysql-server-core–5.5

I then restarted the server using the following command:

sudo shutdown -r now

I then installed MySQL once again using the following command:

sudo apt-get install mysql-server mysql-client

However that process terminated with the error dpkg: error processing mysql-server (--configure)

This time I removed the MySQL using the following command:

sudo aptitude purge libmysqlclient16 libmysqlclient18 mysql-client-core–5.5 mysql-common mysql-server–5.1 mysql-server–5.5 mysql-server-core–5.5

Then I renamed the /etc/mysql/ directory and restarted the server using the following command:

sudo mv /etc/mysql/ /etc/mysql.old
sudo shutdown -r now

Once the server restarted I re-installed MySQL, which completed correctly, by using the following command:

sudo apt-get install mysql-server mysql-client

In comparing my old MySQL configuration file and the new configuration file I noted the difference seems to be the addition of the following line under the [mysqld] section:

pid-file = /var/run/mysqld/mysqld.pid

Also, I had to remove the following two lines that I had added to the new MySQL configuration, as the server wouldn’t start with these two settings under the [mysqld]that I used with MySQL 5.1:

default-collation=utf8_unicode_ci
default-character-set=utf8

With those lines above removed or commented out, I was able to successfully start the server and all of my databases were intact and working.

After reviewing the MySQL 5.5 documentation it looks like the server option default-collation was deprecated in MySQL 5.5.3 in favor of collation-server. The same is true of the server option default-character-set being deprecated in MySQL 5.5.3 in favor of character-set-server

No comments: