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.
Before proceeding, install the
wget package if absent using the command below:
sudo apt-get install wget
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.
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
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
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
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
Y when prompted to continue.
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