How to upgrade MySQL on LEMP 14.04 with 512MB / 1CPU
Note: Purpose of this question is to be a reference for anyone who has problem for upgrading their MySQL5.5 on LEMP 14.04 with 512MB / 1CPU size.
My droplet is created using LEMP 14.04 (One-click Apps) with 512MB/1CPU size. And this is by default will install Ubuntu 14.04 with Mysql 5.5.
mysql -V mysql Ver 14.14 Distrib 5.5.49, for debian-linux-gnu (x86_64) using readline 6.3
When I'am trying to upgrade the MySQL version to 5.6*, following error occur:
start: Job failed to start invoke-rc.d: initscript mysql, action "start" failed. dpkg: error processing package mysql-server-5.6 (--configure): subprocess installed post-installation script returned error exit status 1 Setting up libhtml-template-perl (2.95-1) ... Setting up mysql-common-5.6 (5.6.16-1~exp1) ... Processing triggers for libc-bin (2.19-0ubuntu6) ... Processing triggers for ureadahead (0.100.0-16) ... Errors were encountered while processing: mysql-server-5.6 E: Sub-process /usr/bin/dpkg returned an error code (1)
After hours of searching I found that the failure seems to be because of the default MySQL 5.6 configuration where it requires more memory than it can get in the micro instance. See bug report. See solution
So I’ve taken this steps to fix the errors.
Step 1-Removing MySQL 5.5 Completely
sudo service mysql stop #or mysqld sudo killall -9 mysql sudo killall -9 mysqld sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get autoremove sudo apt-get autoclean sudo deluser mysql sudo rm -rf /var/lib/mysql sudo apt-get purge mysql-server-core-5.5 sudo apt-get purge mysql-client-core-5.5 sudo rm -rf /var/log/mysql sudo rm -rf /etc/mysql
Step 2-Create swap file
Create a 4G swap file:
sudo fallocate -l 4G /swapfile
Change its permission to only root could access and change:
sudo chmod 600 /swapfile
Make it swap:
sudo mkswap /swapfile
sudo swapon /swapfile
Step 3-Install new version of Mysql
sudo apt-get install mysql-client-5.6 mysql-client-core-5.6 sudo apt-get install mysql-server-5.6
That’s it! now lets check if the new version is installed
mysql -V mysql Ver 14.14 Distrib 5.6.31, for debian-linux-gnu (x86_64) using EditLine wrapper
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×