Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS

First, you need to get MySQL installers from https://dev.mysql.com/downloads/mysql/#downloads

I ran following command to get MySQL 5.6.14(32bit):
wget -O mysql-5.6.14.deb https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-debian6.0-i686.deb/from/http://cdn.mysql.com/

Install dependency
sudo apt-get install libaio1

Then install Mysql 5.6.14
sudo dpkg -i mysql-5.6.14.deb

Backup your MySQL 5.5 data
You will need this only if you are upgrading…

cd ~
mkdir backup && cd backup
mysqldump -A –events > dump/alldb.sql

cp -pr /etc/mysql config

service mysql stop
cp -pr /var/lib/mysql/ data

This is your backup folder & data in case if of anything. But if everything when well, you will not need the backups.

Remove MySQL 5.5 Packages
sudo apt-get remove mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5
sudo apt-get autoremove

Setup MySQL 5.6 Startup Script
cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql.server
update-rc.d -f mysql remove
update-rc.d mysql.server defaults

Update environment
sudo nano /etc/environment
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/mysql/server-5.6/bin”
source /etc/environment

Confirm changes
Run this command:
which mysql

Should show:
/opt/mysql/server-5.6/bin/mysql

Update mysql config file
sudo nano /etc/mysql/my.cnf
basedir = /opt/mysql/server-5.6
lc-messages-dir = /opt/mysql/server-5.6/share

Start MySQL 5.6
Its time to start new mysql…
service mysql.server start

If you cannot start mysql server, then install this package:
sudo apt-get install ia32-libs php5-mysql

Then try to start it again.

Final Step
If you are upgrading from mysql, run this command:
mysql_upgrade -u root -p

Otherwise if its a fresh install, run following:
/opt/mysql/server-5.6/scripts/mysql_install_db –user=mysql –datadir=/var/lib/mysql

Enjoy. šŸ™‚

One thought on “Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS

  1. mridul2010Mridul

    Thanks for this nice piece of work.I got a problem to start mysql,I get
    Starting Mysql * Couldn’t find mysql server (/usr/bin/mysqld_safe)

    How can I fix this.Please let me know.
    Thanks

    Reply

Any Comments?