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.

With the release of Debian 9 Stretch, MySQL is no longer available in the Debian’s repositories, and MariaDB has become the default database system. However, in this guide, we are going to install MySQL on a Debian 9 Server for users that want that option over MariaDB.

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 quickly deploy your 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

Step One: Add MySQL Repository The MySQL APT repository provides a simple and convenient way to install and update MySQL products with the latest software packages using Apt. 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:


Step Two: Install MySQL
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.13-1_all.deb

MySQL 8.0 is pre-selected, however, if you want to install another version of MySQL, select MySQL Server & Cluster (Currently selected: mysql-8.0) and choose your preferred MySQL version.

After adding the repo, 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

Next, you will be recommended to use secure password encryption.

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

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

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