How to install MySQL 8.0 on Ubuntu 18.04

4 min readSep 25, 2020


MySQL is an open-source relational database server tool for Linux operating systems. It is widely used in modern web technologies and is part of the popular “LAMP” software stack.


  • The system under Ubuntu control 18.04
  • Access to user account with sudo privileges
  • Terminal window (ctrl-alt-T)
  • APT Package Manager (installed by default)


This article assumes that you are installing the system on the local system.

Step 1: Download MySQL repositories

Your Ubuntu 18.04 installation may not have access to repositories for MySQL.

To load the last repositories, please enter:

wget -c

The system should respond by contacting the server and uploading the .deb configuration file. A progress bar will appear so that you know when the upload is complete.

The -c parameter tells the system to restart loading if it was interrupted. It is also possible that a newer apt-config file has been published since this document was written. You can find a link to the latest file on the MySQL download page.

Step 2. install MySQL repositories.

To install repositories, enter the command:

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

The system should respond by running the setup tool. It will provide you with options for the MySQL version you want to install and any other tools.

Leave the default settings and click “OK” if you are not an experienced user and you have no particular reason to change them.

Step 3: Update repositories

Every time you install new software, you must update the software cache to ensure that you are installing the latest version of

Enter the following in the terminal:

sudo apt-get update

The system should take a few minutes and update the repository cache.

This step configures your system to download MySQL 8 software directly from the source. You will not be able to use your own Ubuntu repositories to download MySQL software until this repository is disabled.

Step 4: Install MySQL

To install MySQL in Ubuntu, run the command:

sudo apt-get install mysql-server

Enter your administrator credentials and the system will install the MySQL server package, client packages, and shared database files.

The installation will prompt you to enter and confirm the user root and password for the MySQL database. This password provides full access to the database, so it must be secure and confidential.

The installer will then display a notification about the new authentication method. Newer authentication is more secure but may cause compatibility problems with old MySQL clients. Click OK, then on the next screen select the authentication method you want to use, then click OK again.

Step 5: Configuring MySQL Security

By default, many basic and important security functions are missing in MySQL. Fortunately, it comes with an installation script that will guide you through the configuration.

To install the MySQL security script, enter it:

sudo mysql_secure_installation

The system will ask you for the root password for MySQL.


The installer will then describe the functions of the Validate Password plugin.

This plugin checks to make sure that any new passwords are sufficiently strong/complex. Enter “y” to enable or “n” to disable. This is your choice, but enabling this plugin is more secure.

The Validate Password plugin has three settings for passwords:

  • Low: passwords must be at least 8 characters long.
  • Medium (default): passwords must be upper case, lower case, 1 digit, and 1 special character.
  • Strong: compares a password to a dictionary file to prevent dictionary or brute-force attacks


Next, the installer will offer you the opportunity to change your password to root. Enter “y” to change the password, or “n” to save the same password that you set in step 4. If you change the password, the installer will have to follow all the requirements set in step 5.


The system will ask you for the following security features. It is recommended to enable (type “y”) all of them unless you have a reason to disable them.

  • Remove anonymous users?
  • Ban root from logging on remotely?
  • Delete the test database and access it?
  • Reboot the privilege tables now?

Step 6 Start, stop or check MySQL service status

In Ubuntu, the MySQL service should run automatically.

To make sure that MySQL works, enter the command:

sudo service mysql status

To stop the service:

sudo service mysql stop

To start the service:

sudo service mysql start

Step 7: Run MySQL to enter commands

Many MySQL commands can be entered from the MySQL shell. This is very similar to the terminal window, but the commands are issued directly to the MySQL service.

Run MySQL with the command:

sudo mysql -u root -p

The system must request a password and then give an idea of the MySQL shell. The command line will change and look like this: mysql>.


Installing MySQL on Ubuntu 18.04 will be very fast!

At this stage, you should have MySQL 8 installed on your Ubuntu server with basic security measures.

You can run additional database tasks via the MySQL shell as described in step 7. Or you can install other plugins or tools to manage your database.

One of the popular tools to manage MySQL in Ubuntu is phpMyAdmin.




We conduct reviews, guides and comparative tests of gaming laptops, monitors, graphics cards, keyboards, mouses, headsets and chairs to help you buy the best ga