How to Install MySQL on Ubuntu 16.04


How to Install MySQL on Ubuntu 16.04

We’ll show you how to install MySQL on Ubuntu 16.04. MySQL is the world’s most popular open-source relational database management system (RDBMS). It is widely used for building web applications and is an important part of the LAMP open-source web application software stack. Installing MySQL on Ubuntu 16.04 is really not so complicated to install, just follow the steps bellow and you should have MySQL installed on Ubuntu 16.04, in few minutes.

1. Connect to your server and update system software

The first thing you need to do is to connect to your server via SSH and update all your system software to the latest version available. Go ahead and run the following command:

sudo apt-get update && sudo apt-get -y upgrade

Once your system is updated, you can proceed with the other steps of this tutorial.

2. Install MySQL on Ubuntu 16.04

The installation of MySQL database server on Ubuntu 16.04 is very easy. All you need to do is to run the command below:

sudo apt-get install mysql-server

The apt package manager will install MySQL database server as well as all its dependencies on your server. During the installation you will be prompted to set a password for the MySQL root user so make sure that you choose a strong one.

3. Harden the MySQL database erver

The first thing you need to do after the installation of MySQL is to harden the database server. MySQL includes a script which will help you to achieve that. Go ahead and run the security script:

sudo mysql_secure_installation

Follow the on-screen messages as follows:

Securing the MySQL server deployment.

Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2

New password:

Re-enter new password:

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done!

4. Start the MySQL Server and enable services on boot

Once you are done with the MySQL secure installation, you can start the MySQL server and enable the service on system boot:

sudo systemctl restart mysql
sudo systemctl enable mysql

One of the most important things when running MySQL on a production server is to get the most out of its performances. If you are a beginner and you do not know how to tune your MySQL server, you can start with a program called MySQLTuner. It will help you to analyze your server and to tune MySQL for better overall performances. We have written a tutorial about how to install and use MySQLTuner on Ubuntu.

Another useful guide that you might like to check is the guide about basic MySQL database administration on a Linux VPS.

If you have a VPS with us, there is no need to Install MySQL on Ubuntu 16.04 yourself. Instead, you can ask our Linux Administrators to Install MySQL on Ubuntu 16.04 for you. They are available 24/7, and can help you out with any issues or requests that you have with MySQL Server on Ubuntu 16.04.

PS. If you like our blog post on How Install MySQL on Ubuntu 16.04, we’d appreciate you sharing this post on social networks by using the shortcuts below, or you can post a comment under the share shortcuts. Thanks.

Tutorials
How to install and integrate SpamAssassin with Exim on a CentOS 7 VPS
Tutorials
How to Reset the MySQL Root Password
Tutorials
How to Install XOOPS 2.5.7 on a CentOS 6 VPS