MySQL is the world's most popular open-source database. With its proven performance, reliability and ease-of-use, MySQL has become the leading database choice for web-based applications. MySQL is a central component of the LAMP open-source web application software stack.

In this guide, we will explain how to install MySQL on an Ubuntu 16.04/18.04 server.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Before proceeding, install the wget package if absent using the command below:

sudo apt-get install wget

Cloudwafer MySQL Installation Ubuntu 1

Step One:
Download the MySQL release package for Ubuntu from the MySQL APT repository. We are installing the latest package as at the time of this post below.

wget https://repo.mysql.com//mysql-apt-config_0.8.12-1_all.deb

Cloudwafer MySQL Installation Ubuntu 2

Step Two:
Install the downloaded MySQL release package with the following command ( or preceded by its path, if you are not running the command inside the folder where the package is):

sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb

Cloudwafer MySQL Installation Ubuntu 3

You will be shown the following option as the MySQL APT Repo features MySQL Server along with a variety of MySQL Components. Select the first option to install MySQL Server. You can always change the configurations later, depending on your own needs

Cloudwafer MySQL Installation Ubuntu 4

Next, select the MySQL Server version to receive when you install. We are selecting MySQL 8.0 in this guide. You can always change the configurations later, depending on your own needs

Cloudwafer MySQL Installation Ubuntu 5

Once the repo has been added, issue the command below to load the package list:

sudo apt-get update

Finally, install MySQL Server using the command below:

sudo apt-get install mysql-server

Cloudwafer MySQL Installation Ubuntu 6

Enter Y when prompted to continue.

You will be required to set a root password, provide the password and confirm it to set.

Cloudwafer MySQL Installation Ubuntu 7

Cloudwafer MySQL Installation Ubuntu 8

Starting and Stopping the MySQL Server
The MySQL server is started automatically after installation. You can check the status of the MySQL server with the following command:

sudo systemctl status mysql

Cloudwafer MySQL Installation Ubuntu 9

Stop the MySQL server with the following command:

sudo systemctl stop mysql

To restart the MySQL server, use the following command:

sudo systemctl restart mysql