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 below and you should have MySQL installed on Ubuntu 16.04, in few minutes.
Table of Contents
Step 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.
Step 2: Install MySQL on Ubuntu 16.04
The installation of the 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 the 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 server on Ubuntu 16.04
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:
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 performance. 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 guides about basic MySQL database administration on a Linux VPS and How to Install MyWebSQL on Ubuntu 16.04.
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 to 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.