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
- MySQL replication enhancements
- Improved security and account management
- JSON improvements
- Improved optimizer
- A new type of backup lock
- Support for common table expressions (both non-recursive and recursive).
- Atomic DDL statement support
- 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 https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb
--2018-06-22 11:39:09-- https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all .deb Resolving dev.mysql.com (dev.mysql.com)... 220.127.116.11 Connecting to dev.mysql.com (dev.mysql.com)|18.104.22.168|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.deb [following] --2018-06-22 11:39:10-- https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.d eb Resolving repo.mysql.com (repo.mysql.com)... 22.214.171.124 Connecting to repo.mysql.com (repo.mysql.com)|126.96.36.199|: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
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'
To confirm that we have successfully installed MySQL server and MySQL client in our system, run
dpkg -l | grep "mysql"
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.
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)
Step 5: Managing MySQL Server using Systemd
By default, MySQL service starts automatically upon installation. To check its status run
systemctl status mysql-server
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
-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
- How to Install LAMP Stack on Ubuntu 18.04
- How to Install LEMP on Ubuntu 18.04
- How to Configure Mariadb Maxscale Master-Slave with Galera Cluster
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 :-)