How to Install MySQL 5.6 on Ubuntu 13 x64 / Debian Linux

Standard

Tutorial for : Installing MySQL 5.6 on Ubuntu 13 x64 Debian Linux

This post should help you to understand how to Install MySQL 5.6 on Ubuntu 13.10 x64 / Debian Linux. As I always say, its very simple process to install it. First head over to MySQL Downloads page and get the 64 bit Debian package for MySQL. Current version out there for general available release is [Note this may change as and when they release minors, so pick what ever is latest from this site at the time of your  installation and modify the commands according to your filename]: mysql-5.6.15-debian6.0-x86_64.deb. Make sure you select Debian Linux from the select platform drop down. Make a note of the md5sum to verify that its legit file after we download it. In our case its 409a79231afb46473f8280a108c9dfdd which is right below download button as shown in the picture below.

mysql_downloads_page

MySQL Downloads Page

Once you click download you will be headed to this page and then copy the link on "No thanks, Just start my download":

mysql56_download_linkNow you have the download link in your clipboard/memory, lets go into the terminal of the machine where we will be installing MySQL. Once you are in the terminal window download the package with wget command as shown below:

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

download_mysql_wgetNow you should have successfully downloaded the Debian package from MySQL website. Calculate the checksum for the file that is downloaded using md5sum command as shown below:

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

mysql 5.6 md5 checksumChecksum that is on the website should match the checksum for the file that we calculated. This check is optional but I recommend it. So far we completed downloading the package and verified its the right file. Before we install MySQL we need to install libaio1 package for MySQL to get installed properly, use the following command to get that package installed:

sudo apt-get install libaio1

Mysql 5.6 libaio1 packageNow add mysql user as MySQL database engine uses mysql user to run itself. Use the following command to add the user:

sudo useradd mysql

mysql system userNow that we have resolved all the dependencies we can install MySQL package, to install MySQL 5.6 package just run the dpkg -i command as shown below:

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

MySQL 5.6 debian package installWe have now successfully installed MySQL Server / Client utilities on this server. We need to do few more steps before we can start using the database engine. First we need to populate the database with default data directories and file. To do that simply run the following command:

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

mysql_install_db_1mysql_install_db_2We need to change ownership of this installation to mysql. The default MySQL installation path for this version on Ubuntu is /opt. The following command will update the ownership of this MySQL installation directory:

sudo chown -R mysql.mysql /opt/mysql/

MySQL directory ownership change

Before we start our database server lets add this new installation bin path to system path. This will allow to access mysql commands from any directory with in this server. Edit "/etc/environment" file and add this new path there.

sudo vi /etc/environment

and append this new path at the end in this file.

:/opt/mysql/server-5.6/bin

environment variable mysqlNow that you have added path to environment, source it to get that in effect.

source /etc/environment

source environmentNow in order to make mysql database server run on system startup or reboots we need to add them to system run levels, so copy the server startup script from our support folder located at /opt/mysql/server-5.6/support-files/mysql.server to /etc/init.d/ folder and update-rc using the following commands:

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

update rc mysqlWe are now at home stretch here, we can now start our MySQL Database server, using the following command:

sudo /etc/init.d/mysql.server start

mysql 5.6 startWe have successfully started our database server now. From here we can either set root password and be done configuring database instance or we can run secure installation to finish our configuration. For production systems I recommend doing secure installation. To do that simply run :

perl /opt/mysql/server-5.6/bin/mysql_secure_installation

mysql_secure_installationFor prod systems create a host specific user with required privileges for your application database. If both web-server and database server are on the same server then I would say don’t allow any remote connections unless you are using an external client to connect to database like Navicat , SQLYog or MySQL Workbench from your home network.

Lets test and see if we can connect to this database server now that we have successfully installed and configured.

mysql -uroot -p

use the password that you have setup when you ran mysql_secure_installation above

mysql56 connectI am going to create a super user that can connect from anywhere for testing remote connections to this database server, to do that simple run the following commands inside database engine:

CREATE USER 'superadmin'@'%' IDENTIFIED BY 'opensourcedbmsadmin';
GRANT ALL ON *.* TO 'superadmin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

super user mysqlNow you can connect with this user to your server from anywhere in the world as long as this ip/hostname is publicly accessible.

mysql workbenchmysql server statusmysql 56 queryThat is all there is to installing MySQL 5.6 on Ubuntu. Please leave comments and feedback. Also I highly recommend this post readers to go through the comments as most of the times issues and work arounds to your problems might be in comments.

Facebooktwitterredditpinterestlinkedinmail

About Prashanth Goriparthi

Data Janitor

23 Comments

  1. Excellent guide, helped me setup MySQL on a personal web server that I am building. I found it much easier to follow than the installation instructions on the MySQL site since the latter was jumping from one page to another for some of the instructions (ex. for creating the mysql user, for adding mysql server to startup, for securing the installation, etc.). Also this guide being specific to Ubuntu helped eliminate the unnecessary instructions for other Linux distros).

    Two minor comments, and I am a noob so I am not sure how valid they are:
    1- For enabling the server at startup you copied mysql.server as is to /etc/init.d. On the MySql site documentation they copy it as mysql. I understand that functionally it doesn’t make any difference, but a noob like me who goes on from following this guide to following the MySQL documentation might at a later stage be looking for mysql in the init.d folder and not finding it.
    2- For creating the mysql user you just did "useradd mysql" but on the MySQL documentation they created a group "groupadd mysql" then added user "adduser -r -g mysql mysql". I am not sure what difference does this make.

    Thank you for your effort

  2. So i went through this way and everything looks good but i can’t find where it stored the my.cnf I ran the command on my linix box to find all my.cnf files and the one is has located in the /opt/mysql/server-5.6/my.cnf but this isn’t the full ini where you can adjust the datadir and such. Any ideas?

  3. Thank you for great tutorial!! Would you maybe consider to write similar tutorial how to install postgresql on ubuntu-13.1??

  4. Great article! I"m sure this will help everyone who needs to update mysql to 5.6.

    One error I am getting towards the end when I ran: perl /opt/mysql/server-5.6/bin/mysql_secure_installation:

    ERROR: can’t create .my.cnf.5611: Permission denied at /opt/mysql/server-5.6/bin/mysql_secure_installation line 105.
    Cleaning up…
    Warning: Could not unlink .my.cnf.5611: No such file or directory
    Warning: Could not unlink .mysql.5611: No such file or directory

    Any idea why this is happening? Thanks.

    • It turns out a reboot was all it needed to make it work. I’m not sure what gives, and I don’t think I can reproduce it again. So in case anyone else has encountered the above, see if a reboot will solve the problem. 🙂

  5. Hi Prashanth Goriparthi,

    I am very Happy with your tutorial & god bless you !!!!

    Please guide me for Master-Master Replication with gtid & Failover technology.

    I have 2 Mysql servrs I wanted to setup a Master-Master replicatio between them.

    Waiting for your kind reply..

    Thank,
    Suraj
    (Pune,Maharashtra)

  6. Hi Prashanth,

    Thanks for a really wonderful tutorial. I just followed it on my Ubuntu 14.04 and it went through like a shot!

    Vithl

  7. I’ve tried with all online guides, even tried different SO’s (ubuntu/fedora/linux mint) and always got problem starting mysql server, THANKS really this guide explained every step in detail and could start my server with NO PROBLEMS! official mysql website should add this!

  8. Hi Prashanth,

    I am not able to do the secure installation using the following command
    perl /opt/mysql/server-5.6/bin/mysql_secure_installation

    It is saying

    suresh@kumar:~$ perl /opt/mysql/server-5.6/bin/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.

    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Enter current password for root (enter for none):

    Please suggest me what to do next

    Thanks,
    SureshKumar

  9. I just have one concern. This is shown being installed on OSX, I even saw the apple menu bar in one of the pictures. This is supposed to be for Ubuntu though. How did this even work on OSX, using a .deb package? OSX doesn’t know what to do with those?

    I’m not trying to be condescending but that is just confusing me. Also, which file did you download? When I go to the website, there are many different tools and even a bundle file. Lastly, there are 2 options that should work with Ubuntu. I can select the Ubuntu or Debian section in mysql downloads.

    If you can answer those questions, I would very much appreciate it. I am currently learning SQL in school and would like a resource for at home. If you have detailed instructions for OSX, I would appreciate that, since 10.9.4 is also available to me.

  10. Hi Prashanth,

    I am facing following issue on Mysql Server.
    Let me explaint my current config.

    Current Config
    Dell R610 with 256GB RAM
    Mysql 5.0
    CentOS 5.5
    Ext3
    Data Folder is near about 200 GB

    Now we have to shift this DB to New Hardware (R620 with 256GB Ram )
    New Config:-
    Dell R620 with 256GB RAM
    Mysql 5.0
    CentOS 6.4
    Ext3

    We cant import the Mysql dump, so we did copy data folder to new server. & its working fine. tell me is it right way to this ?
    Or any other method i can use (I need minimal downtime)

    Issue is that, we are facing issue while replicating this new db.

    Replication Server

    Mysql 5.0
    CentOS 5.5
    Ext3
    Data Folder is near about 200 GB

    Not able to replicate this server.
    so we revert back to our old DB.

    Error on New DB Server is

    SET @@session.collation_database=2048/*!*/;

    Our CTO said that search this error on google , and get this error resolve. but i didnt found proper ans from google. infact this mysql version is outdated now.

    Please suggest me, its very very urgent for me.

    Note: We compile Mysql from source.

    Devendra Joshi
    devendra.joshi9987@gmail.com

  11. I am not able to do the secure installation using the following command
    perl /opt/mysql/server-5.6/bin/mysql_secure_installation

    It is saying

    suresh@kumar:~$ perl /opt/mysql/server-5.6/bin/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.

    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Unable to connect to the server as root user, giving up.
    Cleaning up…

    Please suggest me what to do here to make it connect..

    Thanks in Advance

  12. I am not able to do the secure installation using the following command
    perl /opt/mysql/server-5.6/bin/mysql_secure_installation

    It is saying

    ubuntu@ip-172-31-4-154:~$ perl /opt/mysql/server-5.6/bin/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.

    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Enter current password for root (enter for none):
    mysql: unknown option ‘–connect-expired-password’
    Unable to connect to the server as root user, giving up.
    Cleaning up…

    Please suggest me what to do here to make it connect..

    Thanks in Advance

Leave a Reply

* Captcha [Please fill/solve below] : * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.