Installation de MySQL sur CentOS/RHEL 7/6 & Fedora 31/30

Installation de MySQL sur CentOS/RHEL fedora
MySQL sur CentOS/RHEL 7/6 & Fedora 31/30

introduction

MySQL est un système de gestion de base de données relationnelle (SGBDR) basé sur un serveur client et disponible en tant que logiciel libre. Le SGBDR est un logiciel ou un service utilisé pour créer et gérer des bases de données fondées sur un modèle relationnel.

Ce guide vous montrera comment installer MySQL Server (Community Edition) en utilisant le gestionnaire de paquets par défaut sur CentOS / RHEL 7/6, Fedora 31/30.

Étape 1 : Configuration du Repos Yum.

### On CentOS/RHEL 7 system ###
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
-------------------------------------------
### On CentOS/RHEL 6 system ###
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el6-3.noarch.rpm
-------------------------------------------
### On Fedora 32 system ###
rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc32-1.noarch.rpm
-------------------------------------------
### On Fedora 31 system ###
rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc31-1.noarch.rpm
-------------------------------------------
### On Fedora 30 system ###
rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc30-1.noarch.rpm

Étape 2 : Installer MySQL Community Server.

Le dépôt yum MySQL contient plusieurs configurations de référentiels pour plusieurs versions de MySQL. Alors d’abord désactiver tous les dépôts dans le fichier repo MySQL.

$ sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo

Puis exécutez l’une des commandes suivantes selon votre système d’exploitation pour installer MySQL.

CentOS & Red Hat
$ yum --enablerepo=mysql57-community install mysql-community-server
Fedora
$ dnf --enablerepo=mysql57-community install mysql-community-server

Étape 3 : Démarrer le service MySQL.

Pour démarrer le serveur MySQL, nous pouvons utiliser services ou la commande systemctl.

SysVinit
$ service mysqld start
Systemd
$ systemctl start mysqld.service

Étape 4 : Trouver le mot de passe racine MySQL.

Un mot de passe temporaire pour l’utilisateur root MySQL est établi lors de l’installation de MySQL 5.7. Le mot de passe temporaire généré se trouve dans les fichiers journaux.

$ grep "A temporary password" /var/log/mysqld.log

Output :

[Note] A temporary password is generated for root@server: Hsb65pdh@t1a6

Étape 5 : Configuration de l’installation après MySQL.

Exécutez la commande d’installation sécurisée MySQL mysql_secure_installation pour sécuriser le serveur MySQL après l’installation initiale. Nous recommandons de répondre « oui » à chacune des questions qu’il posera.

$ mysql_secure_installation

Output :

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' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? 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? 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? 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? 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? y
Success.
All done!

Étape 6 : Redémarrer et activer le service MySQL.

Le service MySQL doit être redémarré en utilisant la commande suivante une fois que vous avez terminé l’installation de MySQL et tous les paramètres de base.

SysVinit
$ service mysqld restart
Systemd
$ systemctl restart mysqld.service

De plus, utilisez la commande suivante pour activer le démarrage automatique du service au démarrage du système.

### SysVinit
chkconfig mysqld on
### Systemd
systemctl enable mysqld.service

Étape 7 : Travailler avec MySQL.

Maintenant, connectons-nous au serveur de base de données MySQL. Saisissez le nouveau mot de passe.

Lançons quelques instructions SQL.

### CREATE DATABASE
mysql> CREATE DATABASE DBTest;
 
### CREATE USER ACCOUNT
mysql> CREATE USER 'dbtestuser'@'192.168.10.101' IDENTIFIED BY 'secretPass';
 
### GRANT PERMISSIONS ON DATABASE
mysql> GRANT ALL ON DBTest.* TO 'dbtestuser'@'192.168.1.100';
 
###  RELOAD PRIVILEGES
mysql> FLUSH PRIVILEGES;

Félicitations ! Le serveur MySQL a été installé avec succès sur votre machine.

Laisser un commentaire