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.

MySQL  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).

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

Step 1: Download repository

Download the repository using wget or curl command-line tool

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

Sample Output

Download MySQL 8.0 package
Confirm that you have downloaded using the ls command.

confirm you have downloaded MySql 8.0 deb package

Step 2: Install 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"

Install MySQL 8.0 on Ubuntu 18.04
Next, update Ubuntu 18.04 system

# sudo apt update

Update Ubuntu System

Step 3: Install MySQL server and client (Option 2)

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

You'll be prompted to provide a MySQL root password to access the database. Type the password and hit 'Ok'

Install MySQL 8.0 on Ubuntu 18.04

Confirm the password

Confirm password

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 8.0 server run

# mysql -V

Check mysql version

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

# mysqladmin -u root -p version

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

# mysql_secure_installation

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.

mysql_secure_installation set strong root password

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)

mysql_secure_installation securing the server

Step 5: Managing MySQL Server using Systemd

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

# systemctl status mysql-server

check Mysql status

To stop the service run

# systemctl stop mysql

To start the service run

# systemctl start mysql

To enable MySQL on bootup run

# systemctl enable mysql

Output

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

Conclusion

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. Please leave your suggestions in the below comment section.

Read also:

Jamie Arthur 5:34 am

Comments

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

All comments are subject to moderation.

5 Comments

  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)
    OK

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