How to Install MySQL 8.0 on Ubuntu 18.04

install mysql ubuntu

In this brief tutorial, we'll look at how you can install MySQL 8.0 on Ubuntu 18.04. MySQL is a free and opensource cross-platform database server that is used on many opensource projects and high availability systems such as LAMP and LEMP stacks, IoT to mention but a few.

However, It has been overshadowed by MariaDB in terms of popularity, but still remains an important database server for dozens of open source projects.

New features in MySQL 8.0

  1. MySQL replication enhancements
  2. Improved security and account management
  3. JSON improvements
  4. Improved optimizer
  5. A new type of backup lock
  6. Support for common table expressions (both non-recursive and recursive).
  7. Atomic DDL statement support
  8. Support for regular expression using International Components for Unicode (ICU).

How to install MySQL 8.0 on Ubuntu 18.04

Using root privileges, Login to your Ubuntu 18.04 instance and follow the steps below

Step 1: Add MySQL APT repository

Download the repository using wget or curl command line tool

 wget -c

Sample Output

--2018-06-22 11:39:09--                                                                                        .deb
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: [following]
--2018-06-22 11:39:10--                                                                                        eb
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35970 (35K) [application/x-debian-package]
Saving to: ‘mysql-apt-config_0.8.10-1_all.deb’

mysql-apt-config_0. 100%[===================>]  35.13K  --.-KB/s    in 0.01s

2018-06-22 11:39:10 (3.10 MB/s) - ‘mysql-apt-config_0.8.10-1_all.deb’ saved [359                                                                                        70/35970]

Confirm that you have downloaded using the lscommand.

Step 2: Install The MySQL repository package

Next, using the dpkg package tool, install the MySQL repository package as shown below

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

After running the above command, you get a display prompt giving you a selection of MySQL instances you can choose from. Scroll down and select the last option - "Ok"

Selecting previously unselected package mysql-apt-config.
(Reading database ... 51260 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.10-1_all.deb ...
Unpacking mysql-apt-config (0.8.10-1) ...
Setting up mysql-apt-config (0.8.10-1) ...

Step 3: Install MySQL server and client

Next, run the command below to install MySQL server instance and client which is used for remotely logging to MySQL server

sudo apt install mysql-server mysql-client

You'll be prompted to provide a MySQL root password to access the database

Next, you'll be required to choose the default authentication plugin. Select the first option and hit 'Enter'

install MySQL 8.0 on Ubuntu 18.04

To confirm that we have successfully installed MySQL server and MySQL client in our system, run

dpkg -l | grep "mysql"

Sample output
install MySQL 8.0 on Ubuntu 18.04

Step 4: Securing MySQL installation

By default, MySQL is insecure and therefore, we need to secure the database server. To do so, run


This will present you with a list of prompt questions. You'll first be required to enter the root password - The one you created during MySQL setup. Next, you'll be asked whether to opt for VALIDATE PASSWORD plugin or not. This enables you to test MySQL passwords and improve security.

install MySQL 8.0 on Ubuntu 18.04

Next, you'll be required to answer yes or no to the following questions:

  • Remove anonymous users? (Press y|Y for Yes, any other key for No)
  • Disallow root login remotely? (Press y|Y for Yes, any other key for No)
  • Remove test database and access to it? (Press y|Y for Yes, any other key for No)
  • Reload privilege tables now? (Press y|Y for Yes, any other key for No)

install MySQL 8.0 on Ubuntu 18.04

Step 5: Managing MySQL Server using Systemd

By default, MySQL service starts automatically upon installation. To check its status run

systemctl status mysql-server

install MySQL 8.0 on Ubuntu 18.04

To stop the service run

systemctl stop mysql

To start the service run

systemctl start mysql

To enable MySQL on boot up run

systemctl enable mysql


Synchronizing state of mysql.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable mysql

Step 5: Logging to MySQL database as root

To login to your database engine run

mysql -u root -p

The -u flag specifies the root login. The -p flag prompts for the password.

Type your password and hit Enter to get into MySQL prompt as shown below.

Displaying information about MySQL database server

To display more information about your database server such as the server version and uptime, run

mysqladmin -u root -p version

Read also

Final Word

Congratulations! You have successfully installed and tested your MySQL 8.0 database server! If you wish to interact with the database with a GUI, install PHPMyAdmin utility which will allow you to intuitively administer your databases. That's all for now. We have outlined how you can install  MySQL 8.0 on Ubuntu 18.04. Keep it locked for more insightful posts :-)

Jamie Arthur 5:34 am

About Jamie Arthur

James is a passionate Linux and Windows Systems Administrator with 4 years of experience in Linux, databases and Front-End development. He loves doing research on different Linux distributions and experimenting with installation and configuration of different services and features. His hobbies include swimming, reading novels and playing video games.

Author's All Posts
Like to become part of Linoxide Team and contribute tips? Contact us here.


Your email address will not be published. Required fields are marked *

All comments are subject to moderation.


  1. My installation fails. I select 8.0 and go to okay on the last line and get this warning:
    Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)

    There are no other messages other than this one. After that, all I can install is 5.7