• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Rocky Linux » How To Install MySQL 8.0 on Rocky Linux 9

How To Install MySQL 8.0 on Rocky Linux 9

sammbysamm
October 16, 2023
Install MySQL on Rocky Linux

How To Install MySQL 8.0 on Rocky Linux 9

Share on FacebookShare on LinkedinShare on Whatsapp

Introduction

In the world of web development and data management, MySQL stands as one of the most popular and powerful relational database management systems. Its latest version, MySQL 8.0, comes with enhanced features that provide better performance, security, and scalability. If you’re running an Rocky Linux 9, this article will guide you through the step-by-step process of installing MySQL 8.0, ensuring a smooth setup for efficient data handling.

It is one of the most popular and widely adopted database systems in the world. MySQL is known for its ease of use, scalability, and performance.

OTHER POSTS

How To Install phpMyAdmin on Rocky Linux 9

How To Secure SSH with Fail2Ban on Rocky Linux 9

How To Install Rocky Linux 9.2 Server with Screenshots

Table of Contents

  • Introduction
  • Prerequisites for Installing MySQL 8.0
  • Installing MySQL 8.0 on Rocky Linux 9
  • Method 1 – Installing MySQL 8.0 With Appstream
    • Step 1: System Update
    • Step 2: Install MySQL 8.0
  • Method 2 – Install MySQL 8.0 With Community Edition
    • Step 1: Import MySQL 8.0 Community Edition for Rocky Linux 9
    • Step 2: Check Status and Enable MySQL
    • Step 3: Secure MySQL Installation
    • Step 4: Login to MySQL
      • Create Database MySQL
      • MySQL add User and Grant Privileges
      • Create a Table and Add Data MySQL
  • MySQL Clean up
  • Install Desktop Database Management Tool
  • Conclusion

Prerequisites for Installing MySQL 8.0

Before diving into the installation process, it’s crucial to ensure that your system meets the necessary prerequisites. You will need:

  • A Rocky Linux 9 system with root or sudo access, to set this up, follow our guide Initial Setup Rocky Linux 9 Server: Secure and Efficient You can deploy this on a physical machine or a virtual environment like VMware or VirtualBox.
  • Stable internet connection for downloading packages
  • Basic understanding of Linux commands and MySQL concepts

Installing MySQL 8.0 on Rocky Linux 9

In this guide you are going to learn how to install latest MySQL community server with 2 methods on Rocky Linux 9.

Method 1 – Installing MySQL 8.0 With Appstream

Step 1: System Update

Before proceeding with the installation, it’s recommended to update your system’s package repositories and installed packages. Open the terminal and execute the following commands:

[samm@mysql ~]$ sudo dnf update -y

[samm@mysql ~]$ sudo dnf upgrade --refresh
Extra Packages for Enterprise Linux 9 - x86_64                                                                                                                                     9.5 kB/s | 6.5 kB     00:00    
Extra Packages for Enterprise Linux 9 - x86_64                                                                                                                                     4.5 MB/s |  18 MB     00:04    
Rocky Linux 9 - BaseOS                                                                                                                                                             2.1 kB/s | 4.1 kB     00:01    
Rocky Linux 9 - AppStream                                                                                                                                                          3.3 kB/s | 4.5 kB     00:01    
Rocky Linux 9 - Extras                                                                                                                                                             1.8 kB/s | 2.9 kB     00:01    
Dependencies resolved.
Nothing to do.
Complete!

Step 2: Install MySQL 8.0

MySQL 8.0 is readily available as the default option in Rocky Linux. To install MySQL on your Rocky Linux system, run the following command in the terminal.

[samm@mysql ~]$ sudo dnf install mysql mysql-server

Last metadata expiration check: 1:44:56 ago on Fri 21 Jul 2023 10:26:35 AM EDT.
Dependencies resolved.
===================================================================================================================================================================================================================
 Package                                                        Architecture                               Version                                             Repository                                     Size
===================================================================================================================================================================================================================
Installing:
 mysql                                                          x86_64                                     8.0.32-1.el9_2                                      appstream                                     2.7 M
 mysql-server                                                   x86_64                                     8.0.32-1.el9_2                                      appstream                                      17 M
Installing dependencies:
 libtirpc                                                       x86_64                                     1.3.3-1.el9                                         baseos                                         92 k
 mariadb-connector-c-config                                     noarch                                     3.2.6-1.el9_0                                       appstream                                     9.8 k
 mecab                                                          x86_64                                     0.996-3.el9.3                                       appstream                                     347 k
 mysql-common                                                   x86_64                                     8.0.32-1.el9_2                                      appstream                                      70 k
 mysql-errmsg                                                   x86_64                                     8.0.32-1.el9_2                                      appstream                                     487 k
 mysql-selinux                                                  noarch                                     1.0.5-1.el9_0                                       appstream                                      35 k
 protobuf-lite                                                  x86_64                                     3.14.0-13.el9                                       appstream                                     231 k

Transaction Summary
===================================================================================================================================================================================================================
Install  9 Packages

Total download size: 21 M
Installed size: 179 M
Is this ok [y/N]: 

While there are several optional extra packages available for installation with MySQL on your Rocky Linux system, one popular alternative is to install both the developer kit and the standard MySQL package. This option specifically tailors to developers who are building or testing applications and require access to the complete suite of MySQL development tools.

[samm@mysql ~]$ sudo dnf install mysql mysql-server mysql-devel -y

It’s important to emphasize that individuals utilizing MySQL as a content management system or web server should avoid this particular option. This caution arises from the inclusion of extra components that might become unnecessary for these specific use cases. Nevertheless, for developers aiming to engage with MySQL at a more profound level, the developer kit and standard installation option prove to be excellent selections.

After completing the MySQL installation on your Rocky Linux system, the next crucial step involves verifying the installation to confirm that all functions are operating as anticipated. This verification can be achieved by executing the following command within the terminal.

[samm@mysql ~]$ mysql --version

After successfully verifying your MySQL 8.0 installation on your Rocky Linux system, proceed to activate the service and guarantee its automatic startup every time your system boots up. These two tasks can be accomplished by executing the following command within the terminal.

[samm@mysql ~]$ sudo systemctl enable mysqld --now

Utilizing this command empowers you to activate your MySQL 8.0 installation, guaranteeing its automatic initiation whenever your system boots up. This step holds significance in upholding data accessibility and reliability. With the service starting automatically, you acquire the seamless capability to access and manage your data, effectively eliminating the requirement to manually initiate the MySQL service whenever the need arises.

Method 2 – Install MySQL 8.0 With Community Edition

For those seeking the latest MySQL version, you can achieve your objective by following the subsequent steps. The process commences with the importation of the official RPM package of MySQL 8.0 Community, a task achieved by employing the subsequent command within the terminal.

Step 1: Import MySQL 8.0 Community Edition for Rocky Linux 9

[samm@mysql ~]$ sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm

Retrieving https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm
warning: /var/tmp/rpm-tmp.9qV8Z8: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el9-1  ################################# [100%]

After successfully importing the official RPM package of MySQL 8.0 Community, the subsequent step involves the installation of MySQL 8.0 Community Server. To ensure the installation of the precise version, it becomes imperative to disable the App Stream version and activate the community edition. To complete this task, you can execute the following command within the terminal:

[samm@mysql ~]$ sudo dnf install --disablerepo=appstream mysql-community-server

MySQL 8.0 Community Server                                                                                                                                                         4.3 MB/s | 1.0 MB     00:00    
MySQL Connectors Community                                                                                                                                                         371 kB/s |  27 kB     00:00    
MySQL Tools Community                                                                                                                                                              2.8 MB/s | 366 kB     00:00    
Dependencies resolved.
===================================================================================================================================================================================================================
 Package                                                         Architecture                            Version                                          Repository                                          Size
===================================================================================================================================================================================================================
Installing:
 mysql-community-server                                          x86_64                                  8.0.34-1.el9                                     mysql80-community                                   49 M
Installing dependencies:
 libtirpc                                                        x86_64                                  1.3.3-1.el9                                      baseos                                              92 k
 mysql-community-client                                          x86_64                                  8.0.34-1.el9                                     mysql80-community                                  3.5 M
 mysql-community-client-plugins                                  x86_64                                  8.0.34-1.el9                                     mysql80-community                                  1.4 M
 mysql-community-common                                          x86_64                                  8.0.34-1.el9                                     mysql80-community                                  554 k
 mysql-community-icu-data-files                                  x86_64                                  8.0.34-1.el9                                     mysql80-community                                  2.3 M
 mysql-community-libs                                            x86_64                                  8.0.34-1.el9                                     mysql80-community                                  1.4 M

Transaction Summary
===================================================================================================================================================================================================================
Install  7 Packages

Total download size: 58 M
Installed size: 334 M
Is this ok [y/N]: y

Downloading Packages:
(1/7): mysql-community-common-8.0.34-1.el9.x86_64.rpm                                                                                                                              2.3 MB/s | 554 kB     00:00    
(2/7): mysql-community-client-plugins-8.0.34-1.el9.x86_64.rpm                                                                                                                      2.9 MB/s | 1.4 MB     00:00    
(3/7): mysql-community-client-8.0.34-1.el9.x86_64.rpm                                                                                                                              3.8 MB/s | 3.5 MB     00:00    
(4/7): mysql-community-icu-data-files-8.0.34-1.el9.x86_64.rpm                                                                                                                      2.8 MB/s | 2.3 MB     00:00    
(5/7): mysql-community-libs-8.0.34-1.el9.x86_64.rpm                                                                                                                                2.3 MB/s | 1.4 MB     00:00    
(6/7): libtirpc-1.3.3-1.el9.x86_64.rpm                                                                                                                                             110 kB/s |  92 kB     00:00    
(7/7): mysql-community-server-8.0.34-1.el9.x86_64.rpm                                                                                                                              5.5 MB/s |  49 MB     00:08    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                              5.5 MB/s |  58 MB     00:10     
MySQL 8.0 Community Server                                                                                                                                                         3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x3A79BD29:
 Userid     : "MySQL Release Engineering <[email protected]>"
 Fingerprint: 859B E8D7 C586 F538 430B 19C2 467B 942D 3A79 BD29
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                           1/1 
  Installing       : mysql-community-common-8.0.34-1.el9.x86_64                                                                                                                                                1/7 
  Installing       : mysql-community-client-plugins-8.0.34-1.el9.x86_64                                                                                                                                        2/7 
  Installing       : mysql-community-libs-8.0.34-1.el9.x86_64                                                                                                                                                  3/7 
  Running scriptlet: mysql-community-libs-8.0.34-1.el9.x86_64                                                                                                                                                  3/7 
  Installing       : mysql-community-client-8.0.34-1.el9.x86_64                                                                                                                                                4/7 
  Installing       : libtirpc-1.3.3-1.el9.x86_64                                                                                                                                                               5/7 
  Installing       : mysql-community-icu-data-files-8.0.34-1.el9.x86_64                                                                                                                                        6/7 
  Running scriptlet: mysql-community-server-8.0.34-1.el9.x86_64                                                                                                                                                7/7 
  Installing       : mysql-community-server-8.0.34-1.el9.x86_64                                                                                                                                                7/7 
  Running scriptlet: mysql-community-server-8.0.34-1.el9.x86_64                                                                                                                                                7/7 
  Verifying        : mysql-community-client-8.0.34-1.el9.x86_64                                                                                                                                                1/7 
  Verifying        : mysql-community-client-plugins-8.0.34-1.el9.x86_64                                                                                                                                        2/7 
  Verifying        : mysql-community-common-8.0.34-1.el9.x86_64                                                                                                                                                3/7 
  Verifying        : mysql-community-icu-data-files-8.0.34-1.el9.x86_64                                                                                                                                        4/7 
  Verifying        : mysql-community-libs-8.0.34-1.el9.x86_64                                                                                                                                                  5/7 
  Verifying        : mysql-community-server-8.0.34-1.el9.x86_64                                                                                                                                                6/7 
  Verifying        : libtirpc-1.3.3-1.el9.x86_64                                                                                                                                                               7/7 

Installed:
  libtirpc-1.3.3-1.el9.x86_64                             mysql-community-client-8.0.34-1.el9.x86_64      mysql-community-client-plugins-8.0.34-1.el9.x86_64      mysql-community-common-8.0.34-1.el9.x86_64     
  mysql-community-icu-data-files-8.0.34-1.el9.x86_64      mysql-community-libs-8.0.34-1.el9.x86_64        mysql-community-server-8.0.34-1.el9.x86_64             

Complete!

Now that you have installed the MySQL 8.0 Community Server directly from the MySQL RPM repository, the next step is to verify the success of the installation. You can achieve this by verifying the build version of your MySQL installation using the following command within the terminal.

[samm@mysql ~]$ mysql --version
mysql  Ver 8.0.34 for Linux on x86_64 (MySQL Community Server - GPL)

Step 2: Check Status and Enable MySQL

Now run the following commands to start, enable and check MySQL

[samm@mysql ~]$ sudo systemctl start mysqld

[samm@mysql ~]$ sudo systemctl is-enabled mysqld
enabled

If not enabled, you can enable it using this command:

[samm@mysql ~]$ sudo systemctl enable mysqld

To verify the successful operation of your MySQL service, you can use the following systemctl status command in the terminal.

[samm@mysql ~]$ sudo systemctl status mysqld
● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
     Active: active (running) since Fri 2023-07-21 12:37:19 EDT; 3s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 132963 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
   Main PID: 133036 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 23169)
     Memory: 453.3M
        CPU: 6.792s
     CGroup: /system.slice/mysqld.service
             └─133036 /usr/sbin/mysqld

Jul 21 12:37:02 mysql systemd[1]: Starting MySQL Server...
Jul 21 12:37:19 mysql systemd[1]: Started MySQL Server.

Step 3: Secure MySQL Installation

MySQL includes a security script named mysql_secure_installation, providing you with the tools to establish foundational security measures for your MySQL installation. This script facilitates the implementation of initial security protocols in various ways :

  • You can set a password for root accounts.
  • You can remove root accounts that are accessible from outside the local host.
  • You can remove anonymous-user accounts.
  • Finally, mysql_secure_installation assists in removing the default test database, which is accessible by all users, including anonymous ones. Additionally, it revokes privileges that grant access to databases beginning with the prefix test_.

The script can be simply execute by running:

[samm@mysql ~]$ mysql_secure_installation

If you have installed the MySQL 8.0 Community version and encounter an error regarding the temporary password.

Error: Access denied for user 'root'@'localhost' (using password: NO)

As demonstrated earlier, in cases where the MySQL root password has already been established, you can employ the subsequent command to generate a temporary password. This temporary password allows you to access the MySQL Security script. Within this procedure, you have the opportunity to define a new, robust password for your MySQL installation.

[samm@mysql ~]$ sudo grep 'temporary password' /var/log/mysqld.log

Output :

2023-07-21T16:37:10.458662Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: qcrpd5hOF8)t

When logging into the MySQL Security script with your temporary password, you will be prompted to change it. This password is intended to be temporary and should be updated to a secure password as soon as possible.

The script can be simply execute by running:

[samm@mysql ~]$ 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: 

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) : N

 ... skipping.
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
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
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
 - 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
Success.

All done! 

Step 4: Login to MySQL

To login MySQL execute by running:

[samm@mysql ~]$ mysql -u root -p
Enter password: [Your Password]

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.34 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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.34    |
+-----------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye

Create Database MySQL

To create a database in MySQL, login as shown above and run the below command.

#Create a new database
mysql> CREATE DATABASE sammlinux_db;

#If the database with the same exists
mysql> CREATE DATABASE sammlinux_db;
ERROR 1007 (HY000): Can't create database 'sammlinux_db'; database exists

#Create a database if already exits
mysql> CREATE OR REPLACE DATABASE sammlinux_db;
Query OK, 2 rows affected (0.009 sec)

#First check if a database exists 
mysql> CREATE DATABASE IF NOT EXISTS sammlinux_db;
Query OK, 1 row affected, 1 warning (0.000 sec)

# Check Databases MySQL
mysql> SHOW DATABASES;

MySQL add User and Grant Privileges

To create a user and grant privileges;

#Create user MySQL
CREATE USER 'sammlinux-user'@'localhost' IDENTIFIED BY 'your-password';

#Grant all privileges to the user
GRANT ALL PRIVILEGES ON *.* TO 'sammlinux-user'@'localhost' IDENTIFIED BY 'your-password';

#Grant privileges to a specific database
GRANT ALL PRIVILEGES ON 'sammlinux_db'.* TO 'sammlinux-user'@'localhost';

#Remember to refresh the privileges
FLUSH PRIVILEGES;

#To check user grants in MySQL
SHOW GRANTS FOR 'sammlinux-user'@'locahost';

Create a Table and Add Data MySQL

Once you have created a database, you can create table and add data into it

CREATE TABLE articles (articles_id INT, name VARCHAR(20), channel VARCHAR(20));
INSERT INTO articles (id,name,email) VALUES(56701,"samm","Linux")

MySQL Clean up

To completely remove MySQL, run the following commands.

[samm@mysql ~]$ sudo dnf remove mysql mysql-server

[samm@mysql ~]$ sudo rm -rf /var/lib/mysql/

[samm@mysql ~]$ sudo rm /etc/yum.repos.d/mysql-community*

Install Desktop Database Management Tool

If working with MySQL command line is not your thing, then consider installing a Database Tool to help you. Check out our guide below:

How To Install DBeaver Community on Ubuntu 22.04

Conclusion

In conclusion, installing MySQL 8.0 on Rocky Linux opens up a world of possibilities for efficient database management. By following the steps outlined in this guide, you’ve successfully set up MySQL, secured it, and configured it to your specifications. With MySQL’s features and your newfound knowledge, you’re well-equipped to manage databases and drive data-centric applications on Rocky Linux. Happy database managing!

By following this comprehensive guide, you can confidently install MySQL 8.0 on your Rocky Linux system. The steps outlined above ensure a seamless installation process, allowing you to harness the power of MySQL for effective data management. With MySQL 8.0, you’ll experience improved performance, enhanced security features, and greater flexibility in handling your database needs. So, go ahead and embark on your journey to explore the vast possibilities that MySQL 8.0 brings to the table on your Rocky Linux platform.

Also Read Our Other Guides :

  • How To Install MongoDB 6.0 on Rocky Linux 9
  • How To Install MySQL 8.0 on Ubuntu Server 22.04
  • How To Install MySQL 8.0 on Debian 11
  • How To Install MariaDB 10.6 on Ubuntu Server 22.04
  • How To Install MariaDB 10.6 on Debian 11 Server

Finally, now you have learned how to install MySQL 8.0 on Rocky Linux 9.

Tags: CentOSDatabasesLampMySqlRDBMSRocky Linux

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install PHP 8.2 on Rocky Linux 9

Next Post

How To Install a MinIO Object Storage Server on Rocky Linux (Part 1)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install phpMyAdmin on Rocky Linux 9
Rocky Linux

How To Install phpMyAdmin on Rocky Linux 9

November 11, 2023
Secure SSH with Fail2Ban
Rocky Linux

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
Install Rocky Linux 9.2 Server
Rocky Linux

How To Install Rocky Linux 9.2 Server with Screenshots

October 20, 2023
setup Firewall Using Firewalld Rocky Linux 9
Rocky Linux

How To Set Up a Firewall Using FirewallD on Rocky Linux 9

October 18, 2023
Load More
Next Post
Install a MinIO on Rocky Linux

How To Install a MinIO Object Storage Server on Rocky Linux (Part 1)

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.