GNU/Linux >> Tutoriels Linux >  >> Fedora

Comment installer et configurer Mysql Server 8 sur Fedora 34/35

Mysql est généralement installé dans le cadre de la pile populaire LAMP ou LEMP (Linux, Apache/Nginx, MySQL/MariaDB, PHP/Python/Perl). Il implémente le modèle relationnel et le langage de requête structuré (SQL) pour gérer et interroger les données.

Dans ce guide nous allons installer mysql 8 sur Fedora 34/35

Contenu associé

  • Comment installer et configurer Mariadb dans Fedora 35
  • Comment installer Mysql 8 sur Rocky Linux/Centos 8
  • Comment installer et configurer mysql 8 sur Ubuntu 20.04
  • Comment exécuter Mysql 8 avec Docker et Docker-Compose
  • Utilisation d'Ansible pour installer et initialiser Mysql 8 sur Centos 8
  • Autorisations MySQL – Créer, mettre à jour, supprimer des utilisateurs de la base de données
  • Installer et configurer Nginx, WordPress et Mysql 8 dans Centos 8
  • Créer une instance RDS dans terraform avec un exemple Mariadb

Table des matières

  1. S'assurer que le serveur est à jour
  2. Installation du serveur MySQL 8
  3. Démarrer et activer le service mysql
  4. Sécuriser l'installation de mysql
  5. Tester l'installation de mysql

S'assurer que le serveur est à jour

Avant de continuer, assurons-nous que notre serveur Fedora est à jour. Utilisez cette commande pour mettre à jour les packages du serveur :

sudo dnf -y update

Installation du serveur MySQL 8

Maintenant que nos packages sont mis à jour, nous pouvons procéder à l'installation du serveur mysql. Utilisez cette commande pour rechercher le package sur le serveur qui fournit le serveur mysql.

$ 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

Utilisez cette commande pour vérifier les informations du package répertorié afin de confirmer qu'il fournit la version mysql que nous voulons :

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

Installez maintenant en utilisant cette commande :

sudo dnf install -y community-mysql-server

Une fois installé, vérifiez l'installation à l'aide de cette commande :

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

Démarrage et activation du service mysql

Jusqu'à présent, nous avons réussi à installer le service mysql dans notre système. Le service ne sera pas démarré par défaut, nous devrons donc commencer par lancer la commande suivante :

sudo systemctl start mysqld

Pour permettre au service de démarrer au redémarrage, utilisez cette commande :

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

Vérifiez maintenant l'état du service pour confirmer qu'il est réellement en cours d'exécution :

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

Le Active: active (running) since ... indique que le service est opérationnel.

Pour afficher le journal du service MySQL 8 comme suit à l'aide de la commande journalctl :

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

Sécuriser l'installation de mysql

MySQL inclut un script de sécurité qui vous permet de modifier certaines options de configuration par défaut afin d'améliorer la sécurité de MySQL.

Pour utiliser le script de sécurité, exécutez la commande suivante :

sudo mysql_secure_installation

Cela vous guidera à travers une série d'invites vous demandant si vous souhaitez apporter certaines modifications aux options de sécurité de votre installation MySQL. Ces options incluent :

  • configuration du mot de passe de l'utilisateur root
  • activer le COMPOSANT VALIDATE PASSWORD qui garantit l'utilisation de mots de passe forts
  • Suppression d'utilisateurs anonymes
  • Désactivation de root pour se connecter à distance
  • Suppression des bases de données de test

Voici un exemple de sortie de mon serveur :

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

Test de l'installation de MySQL

Vérifions la version de mysql avec cette commande :

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

Vous pouvez maintenant vous connecter en tant que root utilisateur et le mot de passe spécifié ci-dessus.

$ 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)

Conclusion

Dans cet article, nous avons réussi à installer et tester l'installation de mysql 8 sur Fedora 34/35


Fedora
  1. Comment installer Skype sur Fedora 35/34

  2. Comment installer Apache Maven sur Fedora 35/34

  3. Comment installer Gradle sur Fedora 35/34

  4. Comment installer et configurer Mariadb dans Fedora 35

  5. Comment installer et utiliser Podman dans Fedora 34/35

Comment installer LibreOffice sur Fedora 35/34/33

Comment installer Wine 6.0 sur Fedora 35/34/33

Comment installer Notepad++ sur Fedora 35/34

Comment installer et configurer Drupal sur Fedora 35/34

Comment installer TeamViewer sur Fedora 35/34

Comment installer et configurer MySQL sur Ubuntu 18.04