Install MySQL

MySQL is a database management system. Basically, it will organize and provide access to databases where our site can store information.

MySQL can be acquired and installed using Ubuntu's package manager, apt. A package manager allows us to install most software pain-free from a repository maintained by Ubuntu. For more about the apt, you can check here.

The MySQL can be installed by typing these commands:

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

Note: If you have recently run sudo apt-get update, you don't need run it again. This is because the package index on our computer should already be up-to-date.

During the installation, your server will ask you to select and confirm a password for the MySQL "root" user. This is an administrative account in MySQL that has increased privileges. Think of it as being similar to the root account for the server itself (the one you are configuring now is a MySQL-specific account however).

When the installation is complete, you need to run some additional commands to get your MySQL environment set up securely.

Setup MySQL environment

In order to setup MySQL environment set up securely:

First, you need to tell MySQL to create its database directory structure where it will store its information. You can do this by typing:

sudo mysql_install_db

Afterwards, you need to run a simple security script that will remove some dangerous defaults and lock down access to database system a little bit. Start the interactive script by running:

sudo mysql_secure_installation

You will be asked to enter the password you set for the MySQL root account. Next, it will ask you if you want to change that password. If you are happy with your current password, type "n" for "no" at the prompt.

For the rest of the questions, you should simply hit the "ENTER" key through each prompt to accept the default values. This will remove some sample users and databases, disable remote root logins, and load these new rules so that MySQL immediately respects the changes you have made.

At this point, your MySQL is now set up.