How to install mysql server 5.6 on Ubuntu 14.04 LTS ( Trusty Tahr )

In this practical we will learn, how to install mysql server 5.6 on Ubuntu 14.04 LTS ( Trusty Tahr ).At the time of writing this post, MySQL Server has 5.6 version as stable release (release date – 11 April 2014).

MySQL is a open source relational database management system (RDBMS). It is popularly used in LAMP (Linux,Apache,MySQL,PHP) stack with web application. One the most reliable database and many companies are using it .

Install mysql server 5.6 on Ubuntu 14.04 LTS ( Trusty Tahr )

Installing mysql-server 5.6 is very easy. Follow the given below steps

Step 1: Install MySQL Server 5.6

Install mysql-server 5.6 with apt-get command.

sudo apt-get update
sudo apt-get install mysql-server-5.6

During installation of MySQL Server packages,on your terminal you will screen of setting mysql root password. Hence, give the mysql user root password.

Given below is screenshot of screen.

mysql Ubuntu 14.04

Now it will again ask mysql root password for confirmation. Rewrite the same mysql root password which you have given on first screen.

MySQL Server 5.6 Ubuntu 14.04

Step 2 : Login into MySQL Server

After mysql server installation get finishes , it start the mysql service automatically. Hence, you can login now in MySQL Server with user root.

To login into MySQL Server, use the below given command.It will ask the mysql root password which you have set during mysql server installation.

mysql -u root -p

Given below is the reference from my server

sharad@ubuntu:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 36
Server version: 5.6.17-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.04 sec)

mysql> exit
Bye

Step 3 :MySQL Service to Start/Stop/Restart/Status

(a) To restart the mysql service

sudo service mysql restart

(b) To start mysql Service

sudo service mysql start

(c) To stop mysql service

sudo service mysql stop

(c) To get status of mysql service

sudo service mysql status

NOTE: For start/stop/restart/status of mysql , use service command.

In case, if you are using init.d script (/etc/init.d/mysql), it will show some error as given below.

sharad@ubuntu:~$ 
sharad@ubuntu:~$ sudo /etc/init.d/mysql restart
 * Stopping MySQL database server mysqld                                                                                                  [ OK ] 
 * Starting MySQL database server mysqld                                                                                                         No directory, logging in with HOME=/
                                                                                                                                          [ OK ]
 * Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly.
sharad@ubuntu:~$

Hence, it is good to use service command for start/stop of mysql service

21 thoughts on “How to install mysql server 5.6 on Ubuntu 14.04 LTS ( Trusty Tahr )”

  1. Sharad,

    I used the instructions from the MySQL website which told me to “chown -R mysql .” my installation directory. That directory was ‘/usr/bin’. Has anyone else lost root ownership of their commands (including ‘sudo’, of course), and, if anyone recovered from this, how?

    Stupidly,

    ERandall

    Reply
    • I got myself out of the ownership problem with a PartedMagic rescue disk. But I still have the issue of changing the ownership of the MySQL specific /usr/bin/ files. Can I uninstall and then re-install into a /usr/bin/mysql folder? Using apt-get?

      ERandall

      Reply
  2. Thanks a ton, guy! 😀
    I had a tough time looking or installing MySQL for programming classes.

    You helped me and a lot of people, good sir!
    Thank you so much!

    Sincerely,
    Wellington

    Reply
  3. Hi Sharad,

    Thanks for the link.

    where the config file is stores if i had install mysql locally in ubuntu using apt-get.

    –Amar

    Reply
  4. Thanks for the great article, Sharad! I needed to install MySQL for a database class, but I had just switched to Ubuntu from Windows and was completely lost before finding your tutorial. This method worked PERFECTLY and I’m excited to get to work. Thanks again!

    All the best,
    Lara

    Reply
    • Hello Lara,

      First of all thanks to you also, getting feedback on article is very important for author.
      + I am very happy to see the post is helping to all. Keep reading our blog and share your ideas with others too.

      Regards
      Sharad

      Reply
  5. Hello,
    I had installed mysql 5.5 in my ubuntu 14.04, which is the best or
    more correct way to upgrade to 5.6 without losing the data I already
    have in my database?

    regards,
    Felipe.

    Reply
    • Hello Felipe,

      First take the backup of mysql with mysqldump command. Most important thing is in MySQL 5.6 version , new parameter have been introduced. Best way is take the backup of MySQL, restore it in some test server and then upgrade the MySQL version. By this way you will get to know what are the changes and issue you may face while on upgradation.

      Regards
      Sharad

      Reply
  6. Hello, some days ago I sent you an email about your post about the mysql server. Reading this post I have a doubt, I don’t know if I have to install the mysql server first and the mysql workbench in second place, or is really not important the order in the installation. I’m currently using Ubuntu 14.04.
    I will be very thankful for your answer.

    Best regards.

    Reply
    • Hello Mar,

      Apologize, I have been again out of my city due to official reason. Since in these time, I did not get chance to check the email.

      The order of installation do not matter. MySQL Wordkbench is just simply a tool which helps to connect with MySQL Server and helps to work on awesome stuffs.

      Regards
      Sharad

      Reply

Leave a Comment

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