This article will present the step-by-step installation process of the MySQL server on Ubuntu. For demonstration purposes, I created a virtual machine using Oracle VM virtual box and set up Ubuntu 18.04 on the virtual box. It’s important to note that this guide is suitable for installation on all versions of Ubuntu. I’d recommend you referring to the article Creating a Virtual Machine with Oracle VM Virtual Box for a better understanding of the installing process and creating a virtual machine on Oracle VM virtual box. Also, you may turn to the article How to Install Ubuntu 18.04 for more information about installing Ubuntu 18.04 on the virtual machine.
Install MySQL 8.0 on Ubuntu using PuTTY
The question of how to install MySQL in Ubuntu has a simple answer. We are going to use the PuTTY software to connect to Ubuntu Linux. If you don’t have it installed, get the software from the official page.
Launch PuTTY, specify the hostname, and click Open.
PuTTY prompts for the username and password. Specify these details and hit Enter.
Once we are connected to Linux, connect to the root user by executing the below command:
nisarg@LinuxSQL01:~$ sudo -i
Before we get to install MySQL Server in Ubuntu, we must update the Ubuntu repository. Execute the following command:
root@LinuxSQL01:~# sudo apt-get update
As soon as the repository is updated, we use the wget command to download the latest package of the MySQL Server from MySQL APT Repository:
root@LinuxSQL01:~# wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
After we download it, execute the below command to install the MySQL package:
root@LinuxSQL01:~# sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
The MySQL package configuration wizard opens. On the first screen, you can view the MySQL products list you can install with that wizard – any of the following MySQL servers or components:
- MySQL 5.7
- MySQL 8.0
- MySQL Cluster 7.5
- MySQL Cluster 7.6
- MySQL Cluster 8.0
If you want to change the current selection of MySQL, hit Enter on the first option:
View the list of the MySQL Server versions. We want to install MySQL 8.0, so choose mysql-8.0 and hit Enter.
Back to the first screen of the Wizard, select OK by pressing the down the arrow key and hit Enter.
The latest repository of MySQL 8.0 has been installed.
Now, run the following command to update the repositories:
root@LinuxSQL01:~# sudo apt-get update
When the process is complete, run the following command to install MySQL 8.0:
root@LinuxSQL01:~# sudo apt-get install mysql-server
The installer shows the amount of space to be utilized and prompts for confirmation. Press Y and hit Enter.
The installation process continues. On the next screen, the installer prompts to enter the root password. Specify the appropriate password and hit Enter.
Proceed to the next screen, re-enter the root password, and hit Enter.
MySQL 8.0 uses improved SHA256 password authentication. As we are working with MySQL 8.0, we must update the client connectors and other components. More details are provided on the screen of the installer – review them and hit Enter.
Next, you can choose the default authentication method to be used by MySQL 8.0. We are not updating the client components, so choose Use Legacy Authentication Method and hit Enter.
The installation continues.
When the installation completes, you can view the status of the MySQL service by executing the following command:
root@LinuxSQL01:~# service mysql status
Output:
As you can see, MySQL services are running. Now, let us connect to MySQL Server and run some queries.
Connect to the MySQL Server
First, we check the MySQL Server version by executing the following command:
root@LinuxSQL01:~# mysql -V
Output:
Run the following command to connect to MySQL Server:
root@LinuxSQL01:~# mysql -U root -p
The command prompts for the password of the root user. Specify it and hit Enter.
The connection has been established successfully:
Let us see the list of the databases – run the following query:
mysql> show databases;
Output:
That’s how we can successfully install MySQL on Ubuntu 18.04. In the same way, you can install MySQL in Ubuntu 16.04. If you need to install MySQL in Ubuntu 16.04, these tips are of great help, too.
Install MySQL 8.0 on Ubuntu using Debian Package manager
To install MySQL 8.0 using the Debian package manager, you must first download the MySQL 8.0 package. Open the MySQL Community Downloads page and select Ubuntu Linux from the drop-down menu. It will display the list of packages. We will install the entire package with all tools.
Click download opposite to the Ubuntu Linux 20.10 (x86, 64bit), Deb bundle.
The Oracle web account login page opens. If you have signed up for the oracle account, provide relevant login details and download the package. We are not using any Oracle web account. Thus, click on the start my download link.
The download process begins. Once it is over, we begin the installation.
First, we must extract files from the tar file that contains various Debian packages for installing MySQL client tools and community servers. To do that, right-click on the mysql-server-8.0.23..tar file > Extract.
When the files are extracted, we first install libaio1 library. Execute the following command:
root@LinuxSQL01:~# sudo apt-get install libaio1
Output:
As you can see, the package is already installed. Now, preconfigure the MySQL package by executing the following command:
root@LinuxSQL01:~# sudo dpkg-preconfigure /home/nisarg/Downloads/mysql-server_8.0.23-1ubuntu20.10_amd64.deb-bundle/mysql-community-server_*.deb
This way, we start installing MySQL 8.0. The installation steps are like the installation process done by the MySQL APT repository, as described in this article earlier.
Once the installation process completes, you can view MySQL server services by running the following command:
root@LinuxSQL01:~# service mysql status
Output:
As you can see, MySQL services are running.
Summary
This article explained the step-by-step process of installing MySQL Server 8.0 on Ubuntu Linux. For that, we can use PuTTY or Ubuntu software manager. You choose the method that suits you best, and I hope that it will make your work smoother.
Tags: linux, mysql, ubuntu Last modified: June 27, 2023