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.

46 thoughts on “Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS

  1. I run the MySQL upgrade and receive the below error. Have you encountered this before? Other than this everything went smoothly so thank you very much for this tutorial!

    Looking for ‘mysql’ as: mysql
    Looking for ‘mysqlcheck’ as: mysqlcheck
    FATAL ERROR: Upgrade failed

  2. Same problem of Rob here: during “mysql_upgrade” it says:

    Looking for ‘mysql’ as: mysql
    Looking for ‘mysqlcheck’ as: mysqlcheck
    FATAL ERROR: Upgrade failed

    Thanks

        1. Everything runs fine for me until the upgrade. I was using 5.5.34 and upgraded to 5.6, but when I try mysql_upgrade -u root -p, it gives me:

          Looking for ‘mysql’ as: mysql
          Looking for ‘mysqlcheck’ as: mysqlcheck
          FATAL ERROR: Upgrade failed

      1. mysql_upgrade -u root -p

        Produced…

        “Could not create the upgrade info file ‘/var/lib/mysql/mysql_upgrade_info’ in the MySQL Servers datadir, errno: 13”

        I’ve tried a number of things with the same result: Ran as “sudo”, chmod’ed ‘/var/lib/mysql/mysql_upgrade_info’ to 777.

        There is currently only one line in the file: “5.5.35”.

        Any suggestions? Does this matter if everything else went fine?

  3. You didn’t mention that user should run

    # /opt/mysql/server-5.6/scripts/mysql_install_db

    if he installing MySQL on clean system. I think it’s important for new linux users.

  4. I am getting following error:

    sh: 1: /opt/mysql/server-5.6/bin/my_print_defaults: not found
    Installing MySQL system tables…sh: 1: /opt/mysql/server-5.6/bin/mysqld: not found

  5. When I try to start mysql I get this in the error log:

    131009 16:25:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    /opt/mysql/server-5.6/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
    131009 16:25:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

    I have tried reinstalling libaio1 and also removing+installing it. No change. Any advice? Thanks!

      1. Nice call! The libaio.so.1 file is 64 bit but the mysqld is 32! I must have grabbed the wrong mysql file!

        I’ll remove mysql and start over using a 64 bit version. THANK YOU SO MUCH!

  6. If your mysql server isn’t starting, problem probably is that it can’t find a system message file. Check for it in the error log and execute the following:

    cp /opt/mysql/server-5.6/share/english/errmsg.sys /usr/share/mysql/errmsg.sys

    The server will start now

  7. Starting service mysql on ubuntu with command service mysql.server start and the console say: The server quit without update PID file (/var/run/mysqld/mysqld.pid). Also mysql -u root: can’t could connect to socket at /var/run/mysqld/mysqld.sock. Help me!

    1. I resolve this problem by checking the my.cnf file. I had a duplicated lc-messages-dir line.

  8. It’s been a bit since this tutorial was posted. Here are some issues
    I bumped into. The wget will produce a 404. So, you’ll have to go to that
    site directly. Set up an account. Then you’ll get access to that link where
    you can download mysql manually. Then just change the name to “mysql-5.6.deb”
    and start the tutorial on the second step. For those who might not know,
    if you’re not running as root, you’ll
    need to precede these commands with ‘sudo ‘.

    sudo dpkg -i mysql-5.6.deb

    1. Well, the wget works as long as you type in the whole string, including that strange
      /from/http://cdn.mysql.com/

      at the end. That will surpass Sun login screen.

  9. I get

    user@somewhere:~# wget -O mysql-5.6.deb https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12-debian6.0-x86_64.deb/from/http://cdn.mysql.com/
    –2013-11-27 18:31:14– https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12-debian6.0-x86_64.deb/from/http://cdn.mysql.com/
    Resolving dev.mysql.com (dev.mysql.com)… 137.254.60.11
    Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443… connected.
    HTTP request sent, awaiting response… 404 Not Found
    2013-11-27 18:31:17 ERROR 404: Not Found.

      1. Thanks for update.

        Looks like they removed old download link. It was latest though when I wrote this article!

        I have updated article with latest link now. Thanks again. 🙂

  10. Hey Rahul Bansal,

    That worked just fine to me, thanks! I’m trying to work in some instructions for do the rollback for 5.5 after upgrade using your instructions. But there is a issue related to start mysql service. Did you have this problem? Do you know how to fix it?

    Thanks

  11. Well, I couldn’t find my last comment here. My problemas is related to do a downgrade, after upgrade. The upgrade went fine. Then I removed the /opt/mysql folder. Also, I changed the MySQL.cnf file to the old condiguration. But when I try to install mysql-server-5.5 again, it fails because the mysql service doesn’t start. Is there anything missing here?

  12. Good tutorial, I don’t know if I’m missing something though, I’ve no my.cnf file in /etc – the /etc/mysql directory doesn’t exist. Should I create it and add the two lines?

    sudo find / -iname my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/ndb_rpl/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/rpl_ndb/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/ndb_binlog/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/federated/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/ndb_team/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/rpl/extension/bhs/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/rpl/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/ndb/my.cnf
    /opt/mysql/server-5.6/mysql-test/suite/ndb_big/my.cnf

  13. while executing this command, I am getting the following issue/

    apt-get install libaio1

    Reading package lists…. Done
    Building dependency tree
    Reading state information…. Done
    package libaio1 is not available, but is referred to by another package.
    This may meant hat the package is missing, has been obsoleted, or
    is only available from another source
    E: Package ‘libaio1’ has no installation candidate.

    1. Search for missing package using command apt-cache search libaio1. May be it’s present in another package. Alternatively, try continuing without that.

      I am sorry but I won’t be able to dig deeper as we have switched to percona-mysql.

  14. If you get an error like

    Starting MySQL
     * Couldn't find MySQL server (/opt/mysql/server-5.6/bin/mysql/bin/mysqld_safe)
    

    Then there’s a good chance you didn’t set the basedir correctly. Hope that helps someone! (I managed to miss that step and was confused for a bit)

  15. after this installation my php5 is not working and phpmyadmin and mysql-workbench removes

Comments are closed on this article.
Please use our free support forum for support and discussions.