MySQL is an open-source relational database management system. Its one of the popular relational management system.
Mysql is commonly installed as part of the popular LAMP or LEMP (Linux, Apache/Nginx, MySQL/MariaDB, PHP/Python/Perl) stack. It implements the relational model and Structured Query Language (SQL) to manage and query data.
In this guide we are going to install mysql 8 on OpenSUSE Leap 15.3.
Related Content
- How to install and Configure Mysql Server 8 on Fedora 34/35
- How to install Mysql 8 on Rocky Linux/Centos 8
- How to Install and Set Up mysql 8 on Ubuntu 20.04
- How to run Mysql 8 with Docker and Docker-Compose
- Using Ansible to Install and Initialize Mysql 8 on Centos 8
- Mysql Permissions ā Create, Update, Delete Database Users
- Install and Setup Nginx, WordPress and Mysql 8 in Centos 8
- Create an RDS instance in terraform with a Mariadb Example
Table of Content
- Ensuring the server is Up to date
- Installing Mysql 8 server
- Starting and enabling mysql service
- Securing mysql installation
- Testing mysql installation
Ensuring the Server is Up to date
Before proceeding, let us ensure that our OpenSUSE server is up to date. Use this command to update the server packages:
sudo zypper ref
sudo zypper up -y
Next, let us install common packages that we will need in our tutorial
sudo zypper in curl
Installing Mysql 8 server
Now that our packages are updated, we can proceed to install mysql server. The mysql server packages are not found in the default repositories of OpenSUSE, so we need to set up Mysql Community repositories before proceeding. Use this command to download the reposirory installation package:
> curl -LO https://dev.mysql.com/get/mysql80-community-release-sl15-3.noarch.rpm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 29772 100 29772 0 0 29891 0 --:--:-- --:--:-- --:--:-- 57034
Next, install the rpm package:
sudo zypper install -y ./mysql80-community-release-sl15-3.noarch.rpm
Now refresh the repositories to update the newly added mysql community repos:
sudo zypper ref
Use this command to check the info of the listed package to confirm that it provides the mysql version that we want:
> sudo zypper info mysql-community-server
Loading repository data...
Reading installed packages...
Information for package mysql-community-server:
-----------------------------------------------
Repository : MySQL 8.0 Community Server
Name : mysql-community-server
Version : 8.0.27-1.sl15
Arch : x86_64
Vendor : Oracle and/or its affiliates
Installed Size : 2.83 GiB
Installed : Yes
Status : up-to-date
Source package : mysql-community-8.0.27-1.sl15.src
Summary : A very fast and reliable SQL database server
Description :
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Oracle and/or its affiliates
The MySQL software has Dual Licensing, which means you can use the MySQL
software free of charge under the GNU General Public License
(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
the GPL. See the chapter "Licensing and Support" in the manual for
further info.
The MySQL web site (http://www.mysql.com/) provides the latest news and
information about the MySQL software. Also please see the documentation
and the manual for more information.
This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.
Finally, Install mysql server
sudo zypper install mysql-community-server
Once installed, verify the installation using this command:
> rpm -qi mysql-community-server
Name : mysql-community-server
Version : 8.0.27
Release : 1.sl15
Architecture: x86_64
Install Date: Tue Nov 2 02:56:29 2021
Group : Applications/Databases
Size : 3039099718
License : Copyright (c) 2000, 2021, Oracle and/or its affiliates. Under GPLv2 license as shown in the Description field.
Signature : DSA/SHA256, Wed Sep 29 07:36:37 2021, Key ID 8c718d3b5072e1f5
Source RPM : mysql-community-8.0.27-1.sl15.src.rpm
Build Date : Tue Sep 28 15:13:00 2021
Build Host : pb2-opensuse15-01.appad3iad.mysql2iad.oraclevcn.com
Relocations : (not relocatable)
Packager : MySQL Release Engineering <mysql-build@oss.oracle.com>
Vendor : Oracle and/or its affiliates
URL : http://www.mysql.com/
Summary : A very fast and reliable SQL database server
Description :
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Oracle and/or its affiliates
The MySQL software has Dual Licensing, which means you can use the MySQL
software free of charge under the GNU General Public License
(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
the GPL. See the chapter "Licensing and Support" in the manual for
further info.
The MySQL web site (http://www.mysql.com/) provides the latest news and
information about the MySQL software. Also please see the documentation
and the manual for more information.
This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.
Distribution: (none)
Starting and enabling mysql service
Up to this point we managed to install the mysql service in our system. The service will not be started by default, so we will have to start by issuing the following command:
sudo systemctl start mysql
To enable the service to start on reboots, use this command:
sudo systemctl enable mysql
Now check the status of the service to confirm that it is actually running:
> sudo systemctl status mysql
● mysql.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-11-02 03:00:27 UTC; 31s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 28418 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 4587)
CGroup: /system.slice/mysql.service
└─28418 /usr/sbin/mysqld
Nov 02 03:00:21 ip-10-2-40-60 systemd[1]: Starting MySQL Server...
Nov 02 03:00:27 ip-10-2-40-60 systemd[1]: Started MySQL Server.
TheĀ Active: active (running) since ...
Ā indicates that the service is up and running.
To view the MySQL 8 service log as follows using the journalctl command:
$ sudo journalctl -u mysql -xe
$ sudo tail -f /var/log/mysql/mysqld.log
Securing mysql installation
When the server is started for the first time, the server is initialized, and the following happens (if the data directory of the server is empty when the initialization process begins):
- The SSL certificate and key files are generated in the data directory.
- TheĀ validate_password pluginĀ is installed and enabled.
- A superuser accountĀ
'root'@'localhost'
Ā is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
> sudo grep 'temporary password' /var/log/mysql/mysqld.log
2021-11-02T03:00:23.175267Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nGbo0jV#-OZZ
- Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:
> mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.27
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'nYd3#Mt7Dkh42Zu5M5L!9TAM';
Query OK, 0 rows affected (0.02 sec)
Testing MySQL Installation
Let us check mysql version with this command:
> mysql -V
mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)
Now you can Login as theĀ root
Ā user and the password specified above.
> mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.27
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.27 |
+-----------+
1 row in set (0.00 sec)
Conclusion
In this article, we managed to install and test mysql 8 installation on OpenSUSE Leap 15.3