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
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