Install MySQL on Ubuntu 16.04 [Just 1 Minute Tutorial]

MySQL is widely used by many programmers. You cant simply run a web application without MySQL (This statement is not for people who use alternatives).

MySQL is an Open Source Database Management system registered under general public license. The main thing is that MySQL is now owned by Oracle corporation who bought Java as well.

Previously MySQL is owned by a Swedish company. Let’s dive into the procedure.

You could have read the installation of MySQL on Ubuntu 16.04 server in install lamp stack on ubuntu 16.04 server guide.


This article covers the MySQL installation process in much more detail.

There are only two steps to install MySQL on Ubuntu Server.

  • Update Package Index
  • Install MySQL from repository
  • Configure and secure MySQL


Other than that, you should have the sudo non root user account and then firewall enabled.

We explained both of them in that article, so you need to worry, if you have followed that guide.

Get 50$ Credit on Vulture Clouds Here and Test the Instruction for free.

Install MySQL Ubuntu

To install MySQL, just update the ubuntu package index.

$ sudo apt-get update

And then, install MySQL server from Ubuntu Package repository. Here comes the advantage of Ubuntu. The Open source operating system has many of the applications in its Repository.

You can install them by just executing one simple command. Some times, you wont find any applications. In that case, you have to download the PPA from the main website and add it to your server repository.

To install MySQL, just use the install mysql command.

$ sudo apt-get install mysql-server

During the installation process, you will be asked to enter a root password. Make sure to enter a strong password.

One more important thing is remembering the password. Many guys who have been to the ubuntu server or other linux system for the first time, got confused with the Ubuntu command line interface and MySQL command line.

When they see both of them in the same command prompt, they confuse and close the command prompt and open it again to access the server terminal.

For you guys, here is my small explanation. When you see MySQL in the prompt, then it means you are inside the server and inside MySQL.

Just type exit to come out of MySQL.

MySQL Configuration

You have to secure the MySQL as it is one of the main source for hacker to enter into your site.

Here, i will show you a basic command which will help you to run the MySQL server security checkup.

$ mysql_secure_installation

Just Press Y for all the questions and Only Enter No when MySQL asks you to change the root password which you have set during the installation process.

Once you install and secure the MySQL, now its time to test it.

You can always use Ubuntu’s one of the general command to check status of any application.

$ systemctl status mysql.service

The status MySQL. service will return status of any application.

You should see the following output similar to this one.

 mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
   Active: active (running) since Wed 2017-10-21 10:15:45 UTC; 20min ago
 Main PID: 3754 (mysqld)
    Tasks: 28
   Memory: 1420.3M
      CPU: 1.994s
   CGroup: /system.slice/mysql.service
           └─3754 /usr/sbin/mysqld

MySQL will be mostly running. If not, just use the below command.

$ sudo systemctl start mysql

This command will start running the MySQL.

Also, you can connect to the MySQL from new session of command prompt or from your local machine.

mysqladmin -p -u root

The above command will let you login to the MySQL.

You should get the below output.

mysqladmin  Ver 8.42 Distrib 5.7.16, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Server version      5.7.16-0ubuntu0.16.04.1
Protocol version    10
Connection      Localhost via UNIX socket
UNIX socket     /var/run/mysqld/mysqld.sock
Uptime:         20 min 02 sec

Threads: 1  Questions: 12  Slow queries: 0  Opens: 115  Flush tables: 1  Open tables: 34  Queries per second avg: 0.006

Thats all you have done with the installation of MySQL.


Most of the PHP developers rely on MySQL heavily. Or if you are on to the process of wordress installation, checkout our ubuntu wordpress installation guide.

If you have any questions, contact us or comment here below. We will try to solve the issue.

Make sure to subscribe for our upcoming tutorials to receive the notification first.


Share on facebook
Share on twitter
Share on linkedin

Leave a Comment