How to Install MySQL on Ubuntu 16.04

r00t December 4, 2017

Install MySQL on Ubuntu 16.04

In this tutorial we will show you how to install MySQL on Ubuntu 16.04. We will also install and configure its prerequisites. MySQL is one of the most frequently used database management systems one of website/server applications. It allows users to store their databases and handle them using SQL commands on various platforms.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install MySQL on Ubuntu 16.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Install MySQL.

Installation of MySQL database server on an Ubuntu VPS is very easy. All you need to do is to run the command below:

apt-get install mysql-server

Next, Start the MySQL service and make it auto-start on system boot:

systemctl start mysql
systemctl enable mysql

Step 3. Secure MySQL.

Once the MySQL or MariaDB server has started, the service will then need to be secured. The mysql_secure_installation script will assist with this process by presenting several questions. It is recommended to accept the default action for all questions which is yes.

mysql_secure_installation

You will be given the choice to change the MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases:

  • Set root password? [Y/n] Y
  • Remove anonymous users? [Y/n] Y
  • Disallow root login remotely? [Y/n] Y
  • Remove test database and access to it? [Y/n] Y
  • Reload privilege tables now? [Y/n] Y

Once the database server is secured, check it’s installed version and login to the MySQL command shell as follows:

mysql -V

To access the MySQL instance, run the following command on the terminal.

mysql -u root -p

Congratulation’s! You have successfully install and configured MySQL on your Ubuntu 16.04 server. Thanks for using this tutorial installing MySQL data bases on Ubuntu 16.04 LTS (Xenial Xerus) system.

The Tags:

Leave a Comment

Comments are closed.