GNU/Linux >> LINUX-Kenntnisse >  >> Fedora

So installieren und konfigurieren Sie MySQL Server 8 auf Fedora 34/35

Mysql wird üblicherweise als Teil des beliebten LAMP- oder LEMP-Stacks (Linux, Apache/Nginx, MySQL/MariaDB, PHP/Python/Perl) installiert. Es implementiert das relationale Modell und die Structured Query Language (SQL), um Daten zu verwalten und abzufragen.

In dieser Anleitung werden wir mysql 8 auf Fedora 34/35 installieren

Verwandte Inhalte

  • So installieren und konfigurieren Sie Mariadb in Fedora 35
  • So installieren Sie Mysql 8 auf Rocky Linux/Centos 8
  • So installieren und konfigurieren Sie mysql 8 unter Ubuntu 20.04
  • Wie man Mysql 8 mit Docker und Docker-Compose ausführt
  • Verwenden von Ansible zum Installieren und Initialisieren von MySQL 8 auf Centos 8
  • Mysql-Berechtigungen – Datenbankbenutzer erstellen, aktualisieren, löschen
  • Nginx, WordPress und MySQL 8 in Centos 8 installieren und einrichten
  • Erstellen Sie eine RDS-Instanz in Terraform mit einem Mariadb-Beispiel

Inhaltsverzeichnis

  1. Sicherstellen, dass der Server auf dem neuesten Stand ist
  2. Mysql 8-Server installieren
  3. Starten und Aktivieren des MySQL-Dienstes
  4. Mysql-Installation sichern
  5. Mysql-Installation testen

Sicherstellen, dass der Server auf dem neuesten Stand ist

Bevor wir fortfahren, stellen wir sicher, dass unser Fedora-Server auf dem neuesten Stand ist. Verwenden Sie diesen Befehl, um die Serverpakete zu aktualisieren:

sudo dnf -y update

Mysql 8-Server installieren

Nachdem unsere Pakete aktualisiert wurden, können wir mit der Installation von mysql server fortfahren. Verwenden Sie diesen Befehl, um das Paket auf dem Server zu suchen, der mysql server bereitstellt.

$ sudo dnf search mysql-server
Last metadata expiration check: 2:06:28 ago on Sun 31 Oct 2021 06:18:24 AM UTC.
========================================================================================= Name Matched: mysql-server ==========================================================================================
community-mysql-server.x86_64 : The MySQL server and related files

Verwenden Sie diesen Befehl, um die Informationen des aufgelisteten Pakets zu überprüfen, um zu bestätigen, dass es die gewünschte MySQL-Version bereitstellt:

$ sudo dnf info community-mysql-server
Last metadata expiration check: 2:12:13 ago on Sun 31 Oct 2021 06:18:24 AM UTC.
Installed Packages
Name         : community-mysql-server
Version      : 8.0.26
Release      : 1.fc34
Architecture : x86_64
Size         : 106 M
Source       : community-mysql-8.0.26-1.fc34.src.rpm
Repository   : @System
From repo    : updates
Summary      : The MySQL server and related files
URL          : http://www.mysql.com
License      : GPLv2 with exceptions and LGPLv2 and BSD
Description  : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
             : client/server implementation consisting of a server daemon (mysqld)
             : and many different client programs and libraries. This package contains
             : the MySQL server and some accompanying files and directories.

Installieren Sie jetzt mit diesem Befehl:

sudo dnf install -y community-mysql-server

Überprüfen Sie nach der Installation die Installation mit diesem Befehl:

$ rpm -qi community-mysql-server
Name        : community-mysql-server
Version     : 8.0.26
Release     : 1.fc34
Architecture: x86_64
Install Date: Sun 31 Oct 2021 08:28:55 AM UTC
Group       : Unspecified
Size        : 111652520
License     : GPLv2 with exceptions and LGPLv2 and BSD
Signature   : RSA/SHA256, Tue 17 Aug 2021 04:01:38 PM UTC, Key ID 1161ae6945719a39
Source RPM  : community-mysql-8.0.26-1.fc34.src.rpm
Build Date  : Wed 11 Aug 2021 09:34:44 PM UTC
Build Host  : buildvm-x86-18.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.mysql.com
Bug URL     : https://bugz.fedoraproject.org/community-mysql
Summary     : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.

Mysql-Dienst starten und aktivieren

Bis zu diesem Punkt haben wir es geschafft, den mysql-Dienst in unserem System zu installieren. Der Dienst wird standardmäßig nicht gestartet, daher müssen wir mit dem folgenden Befehl beginnen:

sudo systemctl start mysqld

Verwenden Sie diesen Befehl, damit der Dienst bei Neustarts gestartet werden kann:

$ sudo systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

Überprüfen Sie nun den Status des Dienstes, um zu bestätigen, dass er tatsächlich ausgeführt wird:

$ sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2021-10-31 08:37:07 UTC; 1min 21s ago
   Main PID: 55677 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 4603)
     Memory: 449.0M
        CPU: 3.328s
     CGroup: /system.slice/mysqld.service
             └─55677 /usr/libexec/mysqld --basedir=/usr

Oct 31 08:36:58 new-cloud systemd[1]: Starting MySQL 8.0 database server...
Oct 31 08:36:58 new-cloud mysql-prepare-db-dir[55597]: Initializing MySQL database
Oct 31 08:37:07 new-cloud systemd[1]: Started MySQL 8.0 database server.

Der Active: active (running) since ... zeigt an, dass der Dienst aktiv ist.

So zeigen Sie das MySQL 8-Dienstprotokoll mit dem Befehl journalctl wie folgt an:

$ sudo journalctl -u mysqld -xe
$ sudo tail -f /var/log/mysql/mysqld.log

Mysql-Installation sichern

MySQL enthält ein Sicherheitsskript, mit dem Sie einige Standardkonfigurationsoptionen ändern können, um die Sicherheit von MySQL zu verbessern.

Führen Sie den folgenden Befehl aus, um das Sicherheitsskript zu verwenden:

sudo mysql_secure_installation

Dadurch werden Sie durch eine Reihe von Eingabeaufforderungen geführt, in denen Sie gefragt werden, ob Sie bestimmte Änderungen an den Sicherheitsoptionen Ihrer MySQL-Installation vornehmen möchten. Zu diesen Optionen gehören:

  • Root-Benutzerpasswort einrichten
  • Aktivieren der VALIDATE PASSWORD COMPONENT, die sicherstellt, dass sichere Passwörter verwendet werden
  • Anonyme Benutzer entfernen
  • Root für die Remote-Anmeldung deaktivieren
  • Testdatenbanken entfernen

Hier ist eine Beispielausgabe von meinem Server:

$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.

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
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!

Testen der MySQL-Installation

Lassen Sie uns die MySQL-Version mit diesem Befehl überprüfen:

$ mysql -V
mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

Jetzt können Sie sich als root anmelden Benutzer und das oben angegebene Passwort.

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.26 Source distribution

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>
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.26    |
+-----------+
1 row in set (0.00 sec)

Schlussfolgerung

In diesem Artikel ist es uns gelungen, die Installation von MySQL 8 auf Fedora 34/35

zu installieren und zu testen
Fedora
  1. So installieren Sie Skype auf Fedora 35/34

  2. So installieren Sie Apache Maven auf Fedora 35/34

  3. So installieren Sie Gradle auf Fedora 35/34

  4. So installieren und konfigurieren Sie Mariadb in Fedora 35

  5. So installieren und verwenden Sie Podman in Fedora 34/35

So installieren Sie LibreOffice auf Fedora 35/34/33

So installieren Sie Wine 6.0 auf Fedora 35/34/33

So installieren Sie Notepad++ auf Fedora 35/34

So installieren und konfigurieren Sie Drupal auf Fedora 35/34

So installieren Sie TeamViewer auf Fedora 35/34

So installieren und konfigurieren Sie MySQL unter Ubuntu 18.04