GNU/Linux >> Tutoriels Linux >  >> Cent OS

Comment installer le serveur de base de données MySQL 8 sur CentOS 8

MySQL est un système de base de données gratuit, open source et l'un des plus populaires au monde. Il s'agit d'une plate-forme de gestion de base de données relationnelle alimentée par Oracle Cloud. Il utilise le langage de requête structuré pour ajouter, accéder et gérer le contenu d'une base de données. Il est connu pour sa fiabilité éprouvée, sa rapidité de traitement, sa facilité et sa flexibilité d'utilisation. Plusieurs nouvelles fonctionnalités ont été ajoutées à MySQL 8, notamment la prise en charge de JSON, le dictionnaire de données transactionnelles, la configuration d'exécution persistante, le magasin de documents, les conseils d'optimisation, les rôles SQL, les CTE et les fonctions de fenêtre, les index invisibles et bien d'autres.

Remarque  :Avant d'installer MySQL 8, consultez la documentation officielle, car MySQL 8 comporte de nouvelles fonctionnalités et des modifications qui ont rendu certaines applications incompatibles avec cette version.

Dans ce tutoriel, nous allons vous montrer comment installer la base de données MySQL 8 sur le serveur CentOS 8.

Prérequis

  • Un serveur exécutant CentOS 8.
  • Un mot de passe root est configuré sur votre serveur.

Installer MySQL 8.0 à partir du référentiel MySQL

Par défaut, MySQL 8.0 n'est pas disponible dans le référentiel par défaut de CentOS 8. Vous devrez donc installer le référentiel communautaire MySQL 8.0 sur votre système. Vous pouvez l'installer avec la commande suivante :

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm

Vous devriez voir le résultat suivant :

Retrieving https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
warning: /var/tmp/rpm-tmp.hF0m5V: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el8-1  ################################# [100%]

Ensuite, vérifiez si le référentiel MySQL 8.0 a été activé ou non avec la commande suivante :

dnf repolist all | grep mysql | grep enabled

Vous devriez voir le résultat suivant :

CentOS-8 - AppStream                            3.1 MB/s | 6.5 MB     00:02    
CentOS-8 - Base                                 3.0 MB/s | 5.0 MB     00:01    
CentOS-8 - Extras                               5.3 kB/s | 2.1 kB     00:00    
MySQL 8.0 Community Server                       24 MB/s | 543 kB     00:00    
MySQL Connectors Community                      1.9 MB/s |  19 kB     00:00    
MySQL Tools Community                           677 kB/s |  62 kB     00:00    
mysql-connectors-community         MySQL Connectors Community     enabled:    42
mysql-tools-community              MySQL Tools Community          enabled:    19
mysql80-community                  MySQL 8.0 Community Server     enabled:    31

Ensuite, désactivez temporairement le référentiel AppStream et installez la dernière version de MySQL 8.0 à partir du référentiel de la communauté MySQL avec la commande suivante :

dnf --disablerepo=AppStream install mysql-community-server -y

Une fois l'installation terminée avec succès, vous pouvez vérifier la version installée de MySQL avec la commande suivante :

mysql -Version

Vous devriez voir le résultat suivant :

mysql  Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)

Ensuite, démarrez le service MySQL et activez-le après le redémarrage du système avec la commande suivante :

systemctl start mysqld
systemctl enable mysqld

Vous pouvez également vérifier l'état de MySQL avec la commande suivante :

systemctl status mysqld

Vous devriez voir le résultat suivant :

? mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-03-05 09:37:46 EST; 12s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 3244 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3329 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 12537)
   Memory: 587.7M
   CGroup: /system.slice/mysqld.service
           ??3329 /usr/sbin/mysqld

Mar 05 09:37:01 centos8 systemd[1]: Starting MySQL Server...
Mar 05 09:37:46 centos8 systemd[1]: Started MySQL Server.

Ensuite, c'est toujours une bonne idée d'exécuter le script mysql_secure_installation pour activer certaines fonctionnalités de sécurité supplémentaires, notamment définir un nouveau mot de passe root MySQL, supprimer l'utilisateur anonyme et désactiver la connexion à distance.

Tout d'abord, recherchez le mot de passe root par défaut de MySQL à l'aide de la commande suivante :

cat /var/log/mysqld.log | grep -i 'temporary password'

Sortie :

2020-03-05T14:37:40.273796Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: GN2uNx-vPqwS

Veuillez noter le mot de passe ci-dessus et le modifier à l'aide du script mysql_secure_installation.

mysql_secure_installation

Répondez à toutes les questions comme indiqué ci-dessous :

Securing the MySQL server deployment.

Enter password for user root:   Provide your temporary MySQL root password

The existing password for the user account root has expired. Please set a new password.

New password:   Provide new root password

Re-enter new password:   Re-enter new root 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  Type N and Enter to continue

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

Installer MySQL 8.0 à partir du référentiel AppStream

Vous pouvez également installer MySQL 8.0 à partir du référentiel AppStream par défaut sur CentOS 8. Vous pouvez l'installer avec la commande suivante :

dnf install @mysql -y

Une fois l'installation terminée, vérifiez la version de MySQL avec la commande suivante :

mysql -Version

Vous devriez voir le résultat suivant :

mysql  Ver 8.0.17 for Linux on x86_64 (Source distribution)

Ensuite, démarrez le service MySQL et activez-le après le redémarrage du système avec la commande suivante :

systemctl start mysqld
systemctl enable mysqld

Par défaut, le mot de passe root MySQL n'est pas défini dans CentoS 8. Vous devrez donc le définir à l'aide du script mysql_secure_installation.

mysql_secure_installation

Répondez à toutes les questions comme indiqué ci-dessous :

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

Conclusion

Dans le guide ci-dessus, vous avez appris à installer MySQL 8 à partir du référentiel de la communauté MySQL et du référentiel AppStream sur CentOS 8. Vous pouvez maintenant commencer à créer une nouvelle base de données et des utilisateurs de base de données.


Cent OS
  1. Comment installer Mediawiki sur un serveur CentOS

  2. Comment installer MySQL 8.0 sur CentOS/RHEL 8

  3. Comment installer le serveur de base de données MySQL sur CentOS

  4. Comment installer le serveur MySQL sur CentOS 7

  5. Comment installer MySQL 5.6 sur CentOS 6.x

Comment installer Nginx sur CentOS 8

Comment installer PostgreSQL sur CentOS 8

Comment installer MariaDB sur CentOS 8

Comment installer le serveur FreeIPA sur CentOS 7

Comment installer le serveur de base de données PostgreSQL CentOS 8

Comment installer MySQL 8 sur CentOS 8