How To Install MySQL 5.6 On Ubuntu 12.10 (Including memcached Plugin)

According to What’s New in MySQL 5.6, MySQL 5.6 will bring some performance improvements over MySQL 5.5. If you want to test out MySQL 5.6, you have to install one of the development releases from the MySQL downloads page because there is no stable release yet. This tutorial explains how to install the MySQL 5.6.8rc1 (Linux Generic) development release on an Ubuntu 12.10 server.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

It is important that you haven’t installed any other MySQL version on your system before (not even the one from the Ubutu repositories) because if you did, this tutorial will not work anymore!

Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing

3 Installing MySQL 5.6.8rc1 (Linux Generic)

First we create a user and group called mysql:

groupadd mysql
useradd -r -g mysql mysql

Next install the libaio1 package:

apt-get install libaio1

We will install MySQL in the /usr/local/mysql directory (with /usr/local/mysql/data being the data directory, i.e., the directory which will contain the databases). Therefore we download MySQL to the /usr/local directory now:

MySQL uses the my.cnf file inside /usr/local/mysql, so we don’t have to create one on our own. If you want to change MySQL settings, you can do it in that file.

The downloaded MySQL package comes with the init script mysql.server which we copy to /etc/init.d as follows:

cp support-files/mysql.server /etc/init.d/mysql.server

It is already executable, so we don’t have to change permissions.

We can now start MySQL 5.6 as follows:

/etc/init.d/mysql.server start

To make MySQL start automatically at boot time, run the following command:

update-rc.d mysql.server defaults

The MySQL commands (like mysql, mysql_secure_installation, etc.) are located in the /usr/local/mysql/bin directory which is not in the PATH which means we would have to call these commands with the full or relative path which is cumbersome. To avoid this, we create the following symlink so that we can call all MySQL commands without a path:

ln -s /usr/local/mysql/bin/* /usr/local/bin/

Finally, we should set a MySQL root password:

mysql_secure_installation

root@server1:/usr/local/mysql# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] <– ENTER … Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <– ENTER … Success!

By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <– ENTER … Success!

All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up…
root@server1:/usr/local/mysql#

4 Enabling The memcached Plugin

MySQL 5.6 now provides a NoSQL interface via memcached (see What’s New in MySQL 5.6; this page explains how you can make use of it: http://schlueters.de/blog/archives/152-Not-only-SQL-memcache-and-MySQL-5.6.html). To use this feature, we must enable the memcached plugin – this will then automatically start a memcached daemon on port 11211, which means you don’t have to install memcached separately because it’s all included in the MySQL package.