Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS

I keep hearing good things about MySQL 5.6, so I decided to give it a try, even Ubuntu 12.04 LTS  do not have launchpad repo for it. (atleast, as of July 10, 2013)

Download & Install MySQL 5.6 deb package from official site

You can get MySQL installers from https://dev.mysql.com/downloads/mysql/#downloads

I ran following command to get MySQL 5.6.14

wget -O mysql-5.6.deb http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14-debian6.0-x86_64.deb

Then install Mysql 5.6.x

dpkg -i  mysql-5.6.deb

and install dependency

apt-get install libaio1

Backup 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

At this point your mysql is stopped and you have mysql’s data directory and mysqldump output in ~/backup directory. If all goes well you will not need backups!

Remove MySQL 5.5 Packages

apt-get remove mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5
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

Note: I am not sure why but renaming mysql 5.6’s startup script from mysql.server to mysql was throwing error.

Update Config & Environment settings

Update environment

MySQL 5.6 directory layout is different than Lauchpad packages.

vim /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

Running… which mysql

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

Update mysql config file

vim /etc/mysql/my.cnf
basedir = /opt/mysql/server-5.6
lc-messages-dir = /opt/mysql/server-5.6/share

You may also need to tweak few other settings.

For example:table_cache has been renamed to table_open_cache

Start MySQL 5.6

Its time to start new mysql…

service mysql.server start

If you are facing any issue during startup, refer to mysql error log.

Final Step

If you are upgrading from mysql, run command mysql_upgrade

Otherwise if its a fresh install, run following:

/opt/mysql/server-5.6/scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql

That’s it! Enjoy MySQL 5.6.

Discuss your project
with our experts

No obligation. Limited slots.

Contact Form Business Enquiry

"*" indicates required fields

Please attach any RFP, project specification, or document that you would like to share.
Drop files here or
Max. file size: 5 GB.
    This field is for validation purposes and should be left unchanged.