How to Install MySQL 5.5 on Ubuntu Server 12.04 LTS

For this how to, I am going to document how to install MySQL on an installation of Ubuntu 12.04 LTS

Installing it is a very straight forward and quick process and I prefer to use the terminal. If you are running a GUI, you can also install it through the Ubuntu sofware centre. Typically available with the Ubuntu desktop version.

If you are running the desktop version of Ubuntu, fire up a terminal either by clicking on the icon or by pressing Ctrl + Alt + T

It’s a good idea to update your server package cache before proceeding.

sudo apt-get update

Then, run

sudo apt-get install mysql-server-5.5

Once you have entered the password for sudo access, the installation will proceed. The only thing it will ask you is what to set the root password for MySQL as. You SHOULD set a password up, don’t leave it blank with the intention of doing it later. I would recommend you find a decent password generator too.

Once installation has completed, you just need to check that mysql is running. To do this, run

sudo netstat -tap | grep mysql

If MySQL is running you will see output similar to the following:

tcp  0  0 localhost:mysql  *:*  LISTEN  2480/mysqld

Now test that you can login

mysql -uroot -p

Type in the root password directly after the -p switch without spaces.

You can also view what packages have been installed by typing:

dpkg -l | grep mysql

Which should return output similar to the following:

[email protected]:~$ dpkg -l | grep mysql
ii  libdbd-mysql-perl                4.020-1build2                     Perl5 database interface to the MySQL database
ii  libmysqlclient18                 5.5.35-0ubuntu0.12.04.1           MySQL database client library
ii  mysql-client-5.5                 5.5.35-0ubuntu0.12.04.1           MySQL database client binaries
ii  mysql-client-core-5.5            5.5.35-0ubuntu0.12.04.1           MySQL database core client binaries
ii  mysql-common                     5.5.35-0ubuntu0.12.04.1           MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                     5.5.35-0ubuntu0.12.04.1           MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.5                 5.5.35-0ubuntu0.12.04.1           MySQL database server binaries and system database setup
ii  mysql-server-core-5.5            5.5.35-0ubuntu0.12.04.1           MySQL database server binaries

Job done, you have just installed MySQL 5.5 on Ubuntu 12.04 LTS

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on PinterestBuffer this pageShare on RedditShare on StumbleUpon
About Andy Hayes

Andy Hayes is a DBA working with SQL Server since version 7.0. He has a wonderful wife and two beautiful children. He loves database technology, playing cricket, and blogging. He is passionate about sharing his experiences as a DBA and learning more to further his understanding and knowledge. You can follow me on Twitter, check out my Facebook page or follow me on


  1. Mark Polczynski says:

    Excellent article.
    Only change would be the instructions for entering the password after -p without spaces. You should have the user enter the text exactly as you stated, and tell them they will next be prompted for the password. Thank you for posting this Andy.

  2. Sreejith says:

    thank you
    great help i installed mysql on my ubuntu 12.04

  3. thnx a lot


  1. […] In this post I will detail installing MySQL on Ubuntu 12.04 LTS. I will follow guides from posts at digitalocean (just the MySQL part) and dbadiaries. […]

Speak Your Mind