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
- 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).
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
$ sudo curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
Confirm that you have downloaded using the ls command.
Step 2: Install MySQL repository package
Next, using the dpkg package tool, install the MySQL repository package as shown below
$ sudo dpkg -i mysql-apt-config_0.8.13-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"
Next, update Ubuntu 18.04 system
$ sudo apt update
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
You'll be prompted to provide a MySQL root password to access the database. Type the password and hit 'Ok'
Confirm the password
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 8.0 server run
$ mysql -V
To display more information about your database server such as the server version and uptime, run
$ sudo mysqladmin -u root -p version
Step 4: Securing MySQL installation
By default, MySQL is insecure and therefore, we need to secure the database server. To do so, run
$ sudo 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.
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
$ sudo systemctl status mysql
To stop the service run
$ sudo systemctl stop mysql
To start the service run
$ sudo systemctl start mysql
To enable MySQL on bootup run
$ sudo 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
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.