[EN] How to install MySQL 5.6 on Ubuntu 12.04 (Precise)

This how to will cover the upgrade process of MySQL 5.6 on Ubuntu 12.04 precise. This may also work on Ubuntu 12.10 (quantal) but I haven’t tested it at moment.

DISCLAIMER: I am not responsible for any DATA LOSS you may face when using this how to! Use it at your own risk, create a backup and use your brain! With manual installation you will definitely LOOSE the support of your distribution vendor in case of security updates, be aware of this fact! Thank you!

This how to was created on an up to date (at the day of writing) Ubuntu 12.04.2 LTS machine (use lsb_relase -a to check). MySQL was already running on this machine.

First of all you need to download your new mysql 5.6 server software. You will find the latest version at the download page of mysql.com. Select “Debian Linux” as your platform and depending on your architecture (use uname -i to get this info) you should choose the appropriate package. I have selected x86, 64 bit and will use the package “mysql-5.6.15-debian6.0-x86_64.deb” for the next steps. Hint: Oracle suggests you to login or register, you don’t need it as there is a link “No thanks, just start my download” at the bottom of the page ;-).

Download the package (about 300 MB):

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15-debian6.0-x86_64.deb -O mysql-5.6.15-debian6.0-x86_64.deb

… and install it using dpkg:

dpkg -i  mysql-5.6.15-debian6.0-x86_64.deb

… don’t be a messy and delete the package as you hopefully won’t need it again:

 rm mysql-5.6.15-debian6.0-x86_64.deb

Now look at your fresh mysql 5.6 setup at /opt/mysql/server-5.6/. You should really read the INSTALL-BINARY file as there are some remarks that are good to know and aren’t covered in this howto.

As I mentioned there was already an running instance of mysql on my system. If something wents wrong we really want to have a kind of backup. You could do this on different ways, either you could use mysqldump or to keep it simple stop mysql using service mysql stop and copy your /var/lib/mysql directory using cp -rp /var/lib/mysql /var/lib/mysql.old. This may take a lot of time depending on the size of your databases. In case of emergeny you could then install your distributions mysql version and use your old data.

service mysql stop && cp -rp /var/lib/mysql /var/lib/mysql.old

Now, as you have saved your production data you can remove your Ubuntu version of mysql-server. You can do this by:

apt-get remove mysql-server mysql-server-5.5 mysql-server-core-5.5

Move your my.cnf from /etc/mysql/my.cnf which is the Ubuntu default location to /etc/my.cnf which is the one mysql uses for the start scripts. Do this by mv /etc/mysql/my.cnf /etc/my.cnf and note that the /etc/mysql/conf.d/* files will be included anyway.

mv /etc/mysql/my.cnf /etc/my.cnf

To get mysql started you will need to copy the new startscript to /etc/init.d by cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql.server. As you probably want mysql to start automatically on system startup use update-rc.d mysql.server defaults to create a standard runlevel configuration.

cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql.server && update-rc.d mysql.server defaults

MySQL 5.6 depends on libaio which can installed by:

apt-get install libaio1

Set correct rights for your mysql installation:

chown -R mysql /opt/mysql/server-5.6/
chgrp -R mysql /opt/mysql/server-5.6/

Update some paths in your /etc/my.cnf (use a text editor of your choice, e.g. nano):

basedir = /opt/mysql/server-5.6
lc-messages-dir = /opt/mysql/server-5.6/share

And update your mysql information schema to the latest version:

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

Pitfall: This will create my.cnf in /opt/mysql/server-5.6/ which sets SQL mode to strict. Your applications may have problems with this mode. For compatibility reasons you should DELETE this my.cnf and only rely on your /etc/my.cnf. Delete it by rm /opt/mysql/server-5.6/my.cnf. You won’t be able to overwrite this setting with your /etc/my.cnf and remove STRICT_TRANS_TABLES from your sql_mode. Read more about mysql_install_db here.

rm /opt/mysql/server-5.6/my.cnf

Start mysql by

service mysql.server start

And check your /var/log/syslog for errors. If everything works fine, you should see something like "Version: '5.6.10' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)" and you shoudn’t find any mysql related errors.

Have fun with your freshly upgraded mysql 5.6 server!

Update (29.12.2013): Updated the download url and package name to mysql-5.6.15-debian6.0-x86_64.deb (Thanks hien)!

33 Gedanken zu „[EN] How to install MySQL 5.6 on Ubuntu 12.04 (Precise)

  1. Pingback: [EN] New IPv6 features with MySQL 5.6 | peterchen.net - Peter Hansens Blog

  2. stAn

    The server quit without updating PID file

    If anybody is using apparmor, i had to add these to /etc/apparmor.d/usr.sbin.mysqld (i can’t figure out why it’s always using this profile)

    /etc/my.cnf r,
    /opt/mysql/mysql/server-5.6/lib/plugin/ r,
    /opt/mysql/mysql/server-5.6/lib/plugin/*.so* mr,
    /opt/mysql/mysql/server-5.6/bin/mysqld mr,
    /opt/mysql/mysql/server-5.6/share/** r,

    then run: sudo invoke-rc.d apparmor reload

    and i had to delete InnoDB log files in /var/lib/mysql/ib_… .log as i got “InnoDB plugin registration failed” as i also used mysql 5.5 before. You can check your errors on default 12.04 installation at /var/log/syslog

    now the mysql 5.6 starts with no problems.

  3. Peter

    You need to check for updates manually on mysql.com (or subscribe a mailing list). When there are new updates, you need to check the docs of the new version. I suppose you only have to install the new package and run a tool like mysql_upgrade. But this is guessing only ;-).

  4. Deses

    After following these steps to the letter, my ubuntu just boots in reduced graphics mode… using nvidia.

    Be careful!

    Do you know what could possibly gone wrong?

  5. Peter

    Sorry, I don’t know how this could happen and I even couldn’t imagine how this could impact your X server. I have installed mysql 5.6 on a ubuntu server without graphical frontend.

  6. DXS

    @Deses did you have any success recovering your graphics mode back to normal… my Precise gets stuck right before the login box & seems hopeless to diagnose. Probably libaio messes with the video drivers?

  7. DS

    I was 87% there, but missed a few of the middle-to-last steps. Thank you very much.

  8. daz

    Just did a clean install of Ubuntu server 12.04, then mysql 5.5 and then followed this to the T.

    I got it installed and working properly. The only issue i have is I cant create users and tables. (so yeh its not very good).
    It did work in 5.5

    E.g:
    mysql> CREATE USER ‘myuser’@’localhost’ IDENTIFIED BY ‘mypassword’;
    ERROR 2013 (HY000): Lost connection to MySQL server during query

    Any ideas how to resolve this?

  9. Sanu Thomas

    Hi Peter,
    I was using mysql version 5.5 and i followed your document to upgrade the same ..It all went fine until the second last step .Im also pasting /etc/my.cnf file below.. Please have check and provide me a solution ..
    please find the details below:

    root@atum:/opt/mysql/server-5.6# /opt/mysql/server-5.6/scripts/mysql_install_db –user=mysql –datadir=/var/lib/mysql
    Installing MySQL system tables…2013-04-10 19:56:29 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
    2013-04-10 19:56:29 8051 [Note] InnoDB: The InnoDB memory heap is disabled
    2013-04-10 19:56:29 8051 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2013-04-10 19:56:29 8051 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2013-04-10 19:56:29 8051 [Note] InnoDB: CPU does not support crc32 instructions
    2013-04-10 19:56:29 8051 [Note] InnoDB: Using Linux native AIO
    2013-04-10 19:56:29 8051 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2013-04-10 19:56:29 8051 [Note] InnoDB: Completed initialization of buffer pool
    2013-04-10 19:56:29 8051 [Note] InnoDB: Highest supported file format is Barracuda.
    2013-04-10 19:56:29 8051 [Note] InnoDB: 128 rollback segment(s) are active.
    2013-04-10 19:56:29 8051 [Note] InnoDB: Waiting for purge to start
    2013-04-10 19:56:29 8051 [Note] InnoDB: 1.2.10 started; log sequence number 13225552672
    2013-04-10 19:56:29 8051 [ERROR] /opt/mysql/server-5.6/bin/mysqld: unknown variable ‘table_cache=1024′
    2013-04-10 19:56:29 8051 [ERROR] Aborting

    2013-04-10 19:56:29 8051 [Note] Binlog end
    2013-04-10 19:56:29 8051 [Note] InnoDB: FTS optimize thread exiting.
    2013-04-10 19:56:29 8051 [Note] InnoDB: Starting shutdown…
    2013-04-10 19:56:31 8051 [Note] InnoDB: Shutdown completed; log sequence number 13225552682
    2013-04-10 19:56:31 8051 [Note] /opt/mysql/server-5.6/bin/mysqld: Shutdown complete

    please find my.cnf file below:

    root@atum:~# cat /etc/my.cnf
    #
    # The MySQL database server configuration file.
    #
    # You can copy this to one of:
    # – “/etc/mysql/my.cnf” to set global options,
    # – “~/.my.cnf” to set user-specific options.
    #
    # One can use all long options that the program supports.
    # Run program with –help to get a list of available options and with
    # –print-defaults to see which it would actually understand and use.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html

    # This will be passed to all mysql clients
    # It has been reported that passwords should be enclosed with ticks/quotes
    # escpecially if they contain “#” chars…
    # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
    [client]
    port = 3306
    socket = /var/run/mysqld/mysqld.sock

    # Here is entries for some specific programs
    # The following values assume you have at least 32M ram

    # This was formally known as [safe_mysqld]. Both versions are currently parsed.
    [mysqld_safe]
    socket = /var/run/mysqld/mysqld.sock
    nice = 0

    [mysqld]
    #
    # * Basic Settings
    #
    user = mysql
    pid-file = /var/run/mysqld/mysqld.pid
    socket = /var/run/mysqld/mysqld.sock
    port = 3306
    basedir = /opt/mysql/server-5.6
    datadir = /var/lib/mysql
    tmpdir = /tmp
    lc-messages-dir = /opt/mysql/server-5.6/share
    skip-external-locking
    #
    # Instead of skip-networking the default is now to listen only on
    # localhost which is more compatible and is not less secure.
    bind-address = 127.0.0.1
    #
    # * Fine Tuning
    #
    key_buffer = 16M
    max_allowed_packet = 16M
    thread_stack = 192K
    thread_cache_size = 8
    # This replaces the startup script and checks MyISAM tables if needed
    # the first time they are touched
    myisam-recover = BACKUP
    #max_connections = 100
    #table_cache = 64
    #thread_concurrency = 10
    #
    # * Query Cache Configuration
    #
    query_cache_size = 16M
    #
    # * Logging and Replication
    #
    # Both location gets rotated by the cronjob.
    # Be aware that this log type is a performance killer.
    # As of 5.1 you can enable the log at runtime!
    #general_log_file = /var/log/mysql/mysql.log
    #general_log = 1
    #
    # Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
    #
    # Here you can see queries with especially long duration
    #log_slow_queries = /var/log/mysql/mysql-slow.log
    #long_query_time = 2
    #log-queries-not-using-indexes
    #
    # The following can be used as easy to replay backup logs or for replication.
    # note: if you are setting up a replication slave, see README.Debian about
    # other settings you may need to change.
    #server-id = 1
    #log_bin = /var/log/mysql/mysql-bin.log
    expire_logs_days = 10
    max_binlog_size = 100M
    #binlog_do_db = include_database_name
    #binlog_ignore_db = include_database_name
    #
    # * InnoDB
    #
    # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
    # Read the manual for more InnoDB related options. There are many!
    #
    # * Security Features
    #
    # Read the manual, too, if you want chroot!
    # chroot = /var/lib/mysql/
    #
    # For generating SSL certificates I recommend the OpenSSL GUI “tinyca”.
    #
    # ssl-ca=/etc/mysql/cacert.pem
    # ssl-cert=/etc/mysql/server-cert.pem
    # ssl-key=/etc/mysql/server-key.pem

    [mysqldump]
    quick
    quote-names
    max_allowed_packet = 16M

    [mysql]
    #no-auto-rehash # faster start of mysql but no tab completition

    [isamchk]
    key_buffer = 16M

    #
    # * IMPORTANT: Additional settings that can override those from this file!
    # The files must end with ‘.cnf’, otherwise they’ll be ignored.
    #
    !includedir /etc/mysql/conf.d/

  10. Peter Artikelautor

    Hey Sanu,

    2013-04-10 19:56:29 8051 [ERROR] /opt/mysql/server-5.6/bin/mysqld: unknown variable ‘table_cache=1024′
    2013-04-10 19:56:29 8051 [ERROR] Aborting

    I belief you have copied your old my.cnf. The correct variable name is now table_open_cache instead of table_cache.

    Best Regards,
    Peter

  11. Sanu Thomas

    HI Peter,

    Now i tried giving variable as table_open_cache ,but still getting the same error..
    2013-04-10 23:06:08 9234 [ERROR] /opt/mysql/server-5.6/bin/mysqld: unknown variable ‘table_cache=1024′
    2013-04-10 23:06:08 9234 [ERROR] Aborting

    I exactly followed your doc step by step while instaling 5.6 .but dont know y its same my.cnf file..
    Was this step “mv /etc/mysql/my.cnf /etc/my.cnf” made my cnf file as same as the old..

    Can u provide a sample my.cnf file for mysql 5.6 version .. So that i can compare and use it ..

  12. Peter Artikelautor

    Maybe you have a config file in /etc/mysql/conf.d/ that sets table_cache? You could also try to search/grep in /etc and /opt/mysql/server-5.6 for table_cache:

    grep -ri “table_cache” /opt/mysql/server-5.6
    grep -ri “table_cache” /etc

    Maybe you will find some configuration file that is responsible for the error?

  13. Sanu Thomas

    hey peter,,

    Its working fine now .. a config file in /etc/mysql/conf.d/ was the reason for table_cache variable ..
    Thankyou So much .. was helpless since morning .. so saved me.. lemm gonna sleep now :)

    Hope i can contact u when i have a doubt in mysql :)
    Thankyou again and goodnight ..

  14. Pingback: Hail Data! » Blog Archive » Building from mysql56-playground

  15. Pingback: Install vendor’s mysql .. the debian (quick n dirty) way | moregreyhair

  16. Neal

    Nice article, thanks. I just ran this on a Debian 6 machine almost flawlessly.

    I received the following error when it came to processing the “update-rc.d mysql.server defaults” command:

    # update-rc.d mysql.server defaults
    update-rc.d: using dependency based boot sequencing
    insserv: script mysql.server: service mysql already provided!
    insserv: exiting now!
    update-rc.d: error: insserv rejected the script header

    However logging in to mysql on the CLI tells me it’s now running 5.6.11.

    I restarted the machine and mysql didn’t start automatically, so I removed the /etc/init.d/mysql file and renamed /etc/init.d/mysql.server to /etc/init.d/mysql instead. Now on rebooting MySQL 5.6 starts nicely.

  17. Pingback: How to install MySQL 5.6 on Ubuntu 12.04 (Precise) | RememberLINK

  18. Steve

    Got the error: The server quit without updating PID file. My error log at /var/log/mysql/error.log was kicking out the error: InnoDB: Initializing buffer pool, size = 128.0M
    InnoDB: mmap(137363456 bytes) failed; errno 12 . I was using an AWS micro instance. Evidently they don’t have enough memory to start MYSQL. You can add a swap file to it, which seems to solve it at least for now. But basically you’re looking at going with a proper instance. Just wanted to add this to the comments in case it helps anyone. Excellent instructions overall.

  19. mstfchelik

    Thanks firstly.
    I follow your instructions and it seems its working.But I have one question.After upgrading mysql,If I type
    mysql –version gives me still mysql-5.5.31.If I logged with mysql -uroot -p and check version.It gives 5.6.10.
    Why its different at system?I couldnt understand that

  20. Peter Artikelautor

    Thank you for your feedback! The “mysql” is the mysql client installed by your distribution. The mysql-Server is named mysqld.

    Using a 5.5-client should be no problem as far as I know.

  21. Steve

    The most perfect installation instructions I have ever seen on installing mysql 5.6 on ubuntu. Thank you very much! Worked perfect the first time.

  22. joey

    everything documented worked perfectly. But when I enable GTID i get the following error when starting mysql: * The server quit without updating PID file (/var/run/mysqld/mysqld.pid)

    If I disable GTID it starts up fine. GTID was the whole reason why i wanted to upgrade because of the replication features.

    any ideas?

  23. Ken

    Thanks for your detailed post — the provided installation directions left much to be desired. Your last note on strict mode was particularly helpful.

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>