How to Install MySQL 8.0 on openSUSE Leap 15

MySQL is a relational database management system based on SQL (Structured Query Language). It is one of the most widely used database software for several well-known applications. MySQL is used for data warehousing, e-commerce, and logging applications, but its more commonly used feature is a web database storage and management.

In the following tutorial, you will learn how to install MySQL 8.0 using the Community Release edition.

Prerequisites

  • Recommended OS: openSUSE Leap – 15.x.
  • User account: A user account with sudo or root access.
  • Required Packages: wget

Update Operating System

Update your openSUSE operating system to make sure all existing packages are up to date:

sudo zypper refresh

Once refreshed, run the update command.

sudo zypper update

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@opensuse ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on adding a User to Sudoers on openSUSE.

To use the root account, use the following command with the root password to log in.

su

Import MySQL 8.0 Repository

The first task is to import the MySQL 8.0 repository. Use the following command to download the RPM repository.

openSUSE Leap 15.4:

wget https://dev.mysql.com/get/mysql80-community-release-sl15-4.noarch.rpm

openSUSE Leap 15.3:

wget https://dev.mysql.com/get/mysql80-community-release-sl15-3.noarch.rpm

openSUSE Leap 15.2:

wget https://dev.mysql.com/get/mysql80-community-release-sl15-2.noarch.rpm

openSUSE Leap 15.1:

wget https://dev.mysql.com/get/mysql80-community-release-sl15-1.noarch.rpm

Next, with the version of MySQL 8.0 downloaded for your openSUSE system, import the repository that you just downloaded.

Example:

sudo rpm -ivh mysql80-community-release-sl{version}.noarch.rpm

Example using openSUSE Leap 15.3:

sudo rpm -ivh mysql80-community-release-sl15-3.noarch.rpm

Next, refresh your repositories.

sudo zypper refresh

During the refresh process of the MySQL 8.0 repository, you will find that you are asked to import the signing key, which you can reject or always trust.

Example:

How to Install MySQL 8.0 on openSUSE Leap 15

Type A (For always trust), then press the ENTER KEY to proceed and complete the import.

Install MySQL 8.0 on openSUSE

To install MariaDB, you will need to install the client and the server packages. This can be done as follows:

sudo zypper install mysql-community-server

Example output:

How to Install MySQL 8.0 on openSUSE Leap 15

Type Y and then press the ENTER KEY to proceed with the installation.

Confirm the installation of MySQL 8.0 by checking the version and build:

mysql --version

Example output:

mysql  Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)

Check the Status of the MySQL 8.0 Server

Now you have installed MySQL, and you need first to enable the service.

sudo systemctl enable --now mysql

Next, verify the status of the database software by using the following systemctl command:

systemctl status mysql

Example output:

How to Install MySQL 8.0 on openSUSE Leap 15

To stop the MySQL service:

sudo systemctl stop mysql

To start the MySQL service:

sudo systemctl start mysql

To disable the MySQL service at system startup:

sudo systemctl disable mysql

To activate the MySQL service at system startup:

sudo systemctl enable mysql

To restart the MySQL service:

sudo systemctl restart mysql

Secure MySQL 8 with a security script

When installing  MySQL, the new defaults are considered weak by most standards and raise concerns about the potential of allowing intrusion or exploitation by hackers. One solution is to run the installation security script that came with the  MySQL installation.

First, use the following command to launch the  (mysql_secure_installation) :

sudo mysql_secure_installation

By default, the root password should be blank. If the password has been set for some reason, use the following command to generate a temporary password to log into the MySQL Security script, and during configuration, you will set a new password.

sudo grep 'temporary password' /var/log/mysql/mysqld.log

Example:

How to Install MySQL 8.0 on openSUSE Leap 15

Now re-log back into the MySQL security script using your new temporary password.

sudo mysql_secure_installation

You will be prompted for your root password, and then you will see a question about VALIDATE PASSWORD COMPONENT; this involves defining password complexity checks; for the most part, the default is correct.

Then follow below:

  • Setting the password for root  accounts.
  • Setting the password for the accounts.
  • Removal of root accounts accessible from outside the local host.
  • Removal of anonymous user accounts.
  • Removal of the test database, accessible by default to anonymous users.

Be careful; you use  (Y)  to delete everything. In addition, if you wish, you can reset your root password by creating a new one; you can ignore it if you want, as you already set it during the initial installation with the pop-ups.

Example:

[joshua@opensuse-leap ~]$ mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: <---- SET NEW PASSWORD

Re-enter new password: <---- RE-ENTER NEW PASSWORD

Re-enter new password: 
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y <---- Type Y then press the ENTER KEY (SKIP IF YOU ALREADY JUST SET)

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y <---- Type Y then press the ENTER KEY.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y <---- Type Y then press the ENTER KEY.
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y <---- Type Y then press the ENTER KEY.
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y <---- Type Y then press the ENTER KEY.
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y <---- Type Y then press the ENTER KEY.
Success.

All done! 

Connect to the MySQL 8 Terminal Instance

Now that you have completed the installation security script, connecting to your  MySQL  database can be done using the following:

sudo mysql -u root -p

You will be prompted to enter the root password you defined in the installation configuration or the post-installation security script. Once inside the MySQL service instance, you can run the following command as a test to see it work.

Type the following text  (DISPLAY DATABASE command) :

SHOW DATABASES;

For those new to MySQL, all commands must end with ” ; “

Example:

How to Install MySQL 8.0 on openSUSE Leap 15

TO (CREATE) a database, use the following command.

CREATE DATABASE MYDATATEST;

To delete (DROP) a database, use the following command.

DROP DATABASE MYDATATEST;

To exit the terminal, type the following exit command :

EXIT;

How to Remove (Uninstall) MySQL 8.0

If you no longer want to use the MySQL database and want to delete it entirely, run the following command:

sudo zypper remove mysql-community-server

Example output:

How to Install MySQL 8.0 on openSUSE Leap 15

Type Y, and then press the ENTER KEY to proceed with the removal.

Comments and conclusion

In the tutorial, you learned how to install the latest version of MySQL 8 on openSUSE Leap 15. Additionally, as well as optimization options for specific workloads on specific hardware by mapping user threads to processors, just a few of the new features.

Overall, MySQL 8 provides better performance for read/write workloads, I/O-related workloads, and high contention workloads. Users of older versions of MySQL should consider upgrading, as the performance gains are well worth it.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!