How to Install MySQL 8 on Oracle Linux 7

MySQL is one of the most popular open source database management systems. In this tutorial, we will show you how to install MySQL 8 on Oracle Linux 7.

Posted on

MySQL 8 is the latest major version upgrade of MySQL. It comes with many new features and improvements such as better performance, new SQL functions, new JSON data type support, atomic DDL statements, invisible indexes, etc.

In this tutorial, we will install MySQL 8 on Oracle Linux 7 from the Oracle MySQL Yum repository.

Prerequisites

Before you install MySQL, you need:

  • Oracle Linux 7 fresh installation
  • Non-root user with sudo privileges
  • Internet connection

Step 1 - Add MySQL Yum Repository

Add the MySQL Yum repository:

sudo wget http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm

This will add the package definitions for MySQL 8.

Step 2 - Install MySQL

Install MySQL server:

sudo yum install mysql-server

This will install MySQL 8.0 on your Oracle Linux 7 system.

Step 3 - Start MySQL Service

Start the MySQL service:

sudo systemctl start mysqld

Step 4 - Secure the MySQL Installation

Run the mysql_secure_installation script:

sudo mysql_secure_installation

This will set root password, remove anonymous users etc.

Step 5 - Create MySQL User

Create a dedicated MySQL user for your apps:

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'localhost';

Step 6 - Test MySQL

Connect to the MySQL shell:

mysql -u myuser -p
SHOW DATABASES;

Step 7 - Create Sample Database

Create a test database:

CREATE DATABASE mytestdb;
USE mytestdb;

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50),
  email VARCHAR(50)
);

MySQL 8 is now installed and ready to use!

Conclusion

We have demonstrated how to install MySQL 8 on Oracle Linux 7 using the Oracle MySQL repository. You can now use MySQL for your database applications.

If you want to learn more about MySQL, please use our MySQL tutorials and MySQL Reference.