Oct 31, 2022 2 min read

How to Install MySQL 8.0 in Ubuntu 18.04

To Install MySQL 8.0 on ubuntu 18.04. we will use latest .deb file to configure apt repository on ubuntu. Follow the steps one by one to install MySQL easily.

Install MySql 8 on Ubuntu
Install MySql 8 on Ubuntu
Table of Contents

Step 1 – Add MySQL Apt Repository

Downloading the repository package using the wget or curl tool from the command line.


wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb

Or use curl

curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb

Then install the MySQL repository package using the following dpkg command.

sudo dpkg -i mysql-apt-config_0.8.24-1_all.deb
You Can Disable MySQL Tools & Connectors

Step 2: Install MySQL Server in Ubuntu 18.04

Next, download the latest package information from all configured repositories, including the recently added MySQL repository.

sudo apt update

Then run the following command to install packages for the MySQL community server

sudo apt-get install mysql-server

Through the installation process, you will be asked to enter a password for the root user for your MySQL server, re-enter the password to confirm it and press [Enter].

Set MySQL root user password

You will be asked to select the default authentication plugin to use, then use the right arrow to choose Ok and press [Enter] to complete the package configuration.

MySQL Authentication Plugin

Step 3: Secure MySQL Server Installation

By default, the MySQL installation is insecure.

Execute the below script

sudo mysql_secure_installation

You will be asked to enter the root password you set during installation. Then also choose whether to use the VALIDATE PASSWORD plugin or not.

  • Change the password for root: if you want press Y
  • Remove anonymous users? : y
  • Disallow root login remotely?  : y
  • Remove the test database and access it.  : y
  • Reload privilege tables now?  : y
Secure MySQL Server Installation

Step 4: Managing MySQL Server via Systemd

To Know the Server Status run the below command

sudo systemctl status mysql
Check MySQL Server Status

Step 5: Auto Restart On System or Server Boot

sudo systemctl enable mysql

Finally, to access the MySQL shell

sudo mysql -u root -p
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to BugFix.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.