How to Install MySQL 8 on openSUSE

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 openSUSE.

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 openSUSE Leap from the default repositories.

Prerequisites

Before you install MySQL, you need:

  • openSUSE Leap 15 or higher
  • Non-root user with sudo privileges
  • Internet connection

Step 1 - Add the MySQL Repository

First add the MySQL 8.0 community repository:

sudo zypper addrepo https://download.opensuse.org/repositories/server:/database:/mysql/openSUSE_Leap_15.0/server:database:mysql.repo

This will enable the MySQL 8.0 RPM packages.

Step 2 - Install MySQL

Now install MySQL with:

sudo zypper install mysql-community-server

This will install MySQL 8.0 on openSUSE.

Step 3 - Start MySQL Service

Start the MySQL service:

sudo systemctl start mysql

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 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 is now ready to use!

Conclusion

We have demonstrated how to install MySQL 8 on openSUSE from the default repositories. You can now start using MySQL for your database applications.

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