20.8 C
Texas

How To Install MySQL 8.0 On Ubuntu 20.04

Today we are going to learn that how to Install MySQL 8.0 on Ubuntu 20.04. MySQL is one of the most popular and commonly used Database Management System. Simply follow the below steps for an easy and optimal installation of MySQL 8.0 on Ubuntu 20.04.

Step 1: Update Your System

Hit the below command to get the latest packages installed.

sudo apt update -y

Step 2: Add MySQL Repository in Ubuntu 20.04

Ubuntu already have the default MySQL repository but in our case we’ll add the repository (latest) to install the MySQL. So, type the follwoing command in your terminal.

- Advertisement -
wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb

When the download finished, install the repository with the help of below command

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

You’ll be prompted, select the Ubuntu Bionic & then click “Ok”.

How To Install MySQL 8.0 On Ubuntu 20.04

In the next prompt, choose MySQL 8.0 Server (mostly it is selected by default) and then click “OK”.

How To Install MySQL 8.0 On Ubuntu 20.04

Then in next prompt, choose MySQL 8.0 Version and click “OK”.

How To Install MySQL 8.0 On Ubuntu 20.04

In next step MySQL will be selected by default. Choose the last option OK and then click “OK“.

Step 3: Update MySQL Repository on Ubuntu 20.04

Fire the below command to get the latest repositories packages installed.

sudo apt-get update

And then search for the MySQL 8.0 with the help of apt cache command as shown below:

sabi@Ubuntu20:~$ sudo apt-cache policy mysql-server
mysql-server:
Installed: (none)
Candidate: 8.0.22-1ubuntu18.04
Version table:
8.0.22-1ubuntu18.04 500
500 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 Packages
8.0.22-0ubuntu0.20.04.2 500
500 http://pk.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
500 http://pk.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
8.0.19-0ubuntu5 500
500 http://pk.archive.ubuntu.com/ubuntu focal/main amd64 Packages
500 http://pk.archive.ubuntu.com/ubuntu focal/main i386 Packages

Step 4: Install MySQL on Ubuntu 20.04

As we’ve seen above the MySQL 8.0 is listed in our Ubuntu 20.04 system, so install it by typing the below command in terminal. Press “Y” when prompted to continue.

sabi@Ubuntu20:~$ sudo apt install mysql-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
apache2-data apache2-utils galera-3 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl
libdbd-mysql-perl libdbi-perl libfcgi-perl libfprint-2-tod1 libhtml-template-perl
libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
libreadline5 libsnappy1v5 libterm-readkey-perl mariadb-common nginx-common nginx-core socat
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libmecab2 libtinfo5 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common
mysql-community-client mysql-community-client-core mysql-community-client-plugins mysql-community-server
mysql-community-server-core
The following packages will be REMOVED:
mariadb-client mariadb-client-10.3 mariadb-client-core-10.3 mariadb-server mariadb-server-10.3
mariadb-server-core-10.3
The following NEW packages will be installed:
libmecab2 libtinfo5 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-community-client
mysql-community-client-core mysql-community-client-plugins mysql-community-server
mysql-community-server-core mysql-server
The following packages will be upgraded:
mysql-common
1 upgraded, 12 newly installed, 6 to remove and 5 not upgraded.
Need to get 31.1 MB of archives.
After this operation, 96.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Provide the root password when prompted to continue. Re-enter to verify the password.

Use the strong password encryption as recommended by MySQL.

Step 5: MySQL Secure Installation

For security reasons, to secure the installation type

sabi@Ubuntu20:~$sudo mysql secure_installation
Enter current password for root (enter for none):
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: Y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Using existing password for root.
Estimated strength of the password: 25
Change the password for root ? ((Press y|Y for Yes, any other key for No) : d
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Then Press “Enter“. When prompts for root password, provide the root password.

Verify the MySQL version with the help of below command after login to the MySQL.

sudo mysql -u root -p
SELECT VERSION()
| VERSION() |
+-----------+
| 8.0.21 |
+-----------+
1 row in set (0.00 sec)

Step 6: Enable MySQL Remote Access (Optional)

By default remote access for MySQL is disabled, you can enable it if you needed by editing the below file.

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Here search for the line “bind_address” & do the changes as shown below:

#By default we only accept connections from localhost
bind-address = 127.0.0.1
bind-address = 0.0.0.0

Then save and exit the file.

And restart mysql

sudo systemctl restart mysql

And allow the remote connections through the firewall.

sudo ufw allow from to any port 3306
sudo ufw enable

To access the database from remote system, type

mysql -u user -h database_server_ip -p

So, this is how you can install MySQL 8.0 on Ubuntu 20.04

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article