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.
[sourcecode language=’sql’]
sudo apt-get update
[/sourcecode]
Then, run
[sourcecode language=’sql’]
sudo apt-get install mysql-server-5.5
[/sourcecode]
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
[sourcecode language=’sql’]
sudo netstat -tap | grep mysql
[/sourcecode]
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
[sourcecode language=’sql’]
mysql -uroot -p
[/sourcecode]
Type in the root password directly after the -p switch without spaces.
You can also view what packages have been installed by typing:
[sourcecode language=’sql’]
dpkg -l | grep mysql
[/sourcecode]
Which should return output similar to the following:
andrew@ubuntu-1:~$ 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
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.
Sreejith says
thank you
great help i installed mysql on my ubuntu 12.04
krish says
thnx a lot