MySQL est un système de gestion de base de données gratuit couramment utilisé dans les applications Web pour stocker et récupérer des enregistrements et des informations. Il a été initialement développé par MYSQL AB, maintenant propriété d'Oracle Corporation.
MySQL était la base de données principale du système d'exploitation Linux jusqu'à ce que MariaDB, un fork de MySQL, entre en scène.
Ici, nous allons voir comment installer MySQL 8.0 sur Fedora 35 / Fedora 34.
Ajouter un référentiel MySQL
Tout d'abord, ajoutez le référentiel officiel de MySQL pour installer le serveur de la communauté MySQL.
# Fedora 35 sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc35-1.noarch.rpm # Fedora 34 sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc34-2.noarch.rpm
Ensuite, vérifiez si le référentiel MySQL est activé à l'aide de la commande suivante.
sudo dnf repolist all | grep mysql | grep enabled
Sortie :
mysql-connectors-community MySQL Connectors Community enabled mysql-tools-community MySQL Tools Community enabled mysql80-community MySQL 8.0 Community Server enabled
Installer le serveur de communauté MySQL
Installer MySQL 8.0
Après avoir ajouté le référentiel, utilisez le dnf
commande pour installer le serveur de communauté MySQL 8.0.
sudo dnf install -y mysql-community-server
Installer MySQL 5.7
MySQL 5.7 n'est PAS disponible pour Fedora 35 et Fedora 34Après l'installation du serveur MySQL, vous pouvez démarrer le service à l'aide de la commande suivante.
sudo systemctl start mysqld
Ensuite, activez le service MySQL au démarrage du système.
sudo systemctl enable mysqld
Enfin, vérifiez l'état du serveur MySQL à l'aide de la commande suivante.
sudo systemctl status mysqld
Mot de passe racine MySQL initial
Dans Fedora, vous pouvez trouver le mot de passe root initial de MySQL dans /var/log/mysqld.log
. Vous pouvez utiliser la commande ci-dessous pour obtenir le mot de passe initial à partir du fichier journal.
sudo cat /var/log/mysqld.log | grep -i 'temporary password'
Sortie :
2021-11-27T07:52:26.014940Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: mSa1,T_!xPyp
Serveur MySQL sécurisé
Maintenant, vous devez exécuter mysql_secure_installation
pour sécuriser votre installation MySQL. Cette commande s'occupe de définir le mot de passe root, de supprimer les utilisateurs anonymes, d'interdire la connexion root à distance, etc.
sudo mysql_secure_installation
Sortie :
Securing the MySQL server deployment. Enter password for user root: << Enter the initital MySQL root password The existing password for the user account root has expired. Please set a new password. New password: << Enter new MySQL root password Re-enter new password: << Re-enter new MySQL 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 as we have already set new password ... 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 << Type Y to remove anonymous users 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 << Type Y to disallow root login remotely 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 << Type Y to remove test database - 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 << Type Y to reload privilege tables Success. All done!
Travailler avec le serveur MySQL
Maintenant, vous pouvez utiliser le mysql
commande pour se connecter au serveur MySQL et effectuer les activités souhaitées.
mysql -u root -p
Sortie :
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 8.0.27 MySQL Community Server - GPL 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>
Conclusion
C'est tout. J'espère que vous avez appris à installer MySQL 8.0 sur Fedora 35 / Fedora 34.