MySQL
Introduction
Cet article décrit l'installation d'un serveur de base de données MySQL
Prérequis
Un serveur virtuel sous Rocky 9
Installation
Installation du paquet
sudo dnf install mysql-server
Démarrage du service
sudo systemctl start mysqld
Status du service
sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset: disabled)
Active: active (running) since Sun 2023-11-19 07:39:49 CET; 7s ago
Process: 1540 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 1562 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Main PID: 1637 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 12105)
Memory: 458.6M
CPU: 3.579s
CGroup: /system.slice/mysqld.service
└─1637 /usr/libexec/mysqld --basedir=/usr
Nov 19 07:39:44 rocky91.gmolab.net systemd[1]: Starting MySQL 8.0 database server...
Nov 19 07:39:44 rocky91.gmolab.net mysql-prepare-db-dir[1562]: Initializing MySQL database
Nov 19 07:39:49 rocky91.gmolab.net systemd[1]: Started MySQL 8.0 database server.
Activer le service
sudo systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
Sécurisation de MySQL
sudo mysql_secure_installation
Taper y puis ENTER
Taper 2 puis ENTER
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
Entrer un mot de passe puis ENTER
Valider votre mot de passe puis ENTER
Attention
Conservez précieusement ce mot de passe. C'est le mot de passe admin de votre serveur MySql
Taper y puis ENTER aux autres questions posées.
Vérification
mysqladmin -u root -p version
Enter password:
Saisir le mot de passe puis ENTER
mysqladmin Ver 8.0.32 for Linux on x86_64 (Source distribution)
Copyright (c) 2000, 2023, 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.
Server version 8.0.32
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 17 min 14 sec
Threads: 2 Questions: 18 Slow queries: 0 Opens: 133 Flush tables: 3 Open tables: 49 Queries per second avg: 0.017
mysql -u root -p
Enter password:
Saisir le mot de passe puis ENTER
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.32 Source distribution
Copyright (c) 2000, 2023, 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>
À partir de là, vous pouvez commencer à utiliser votre installation MySQL pour créer des bases de données et commencer à exécuter des requêtes.
Tutoriel
Implémentez vos bases de données relationnelles avec SQL
| Version | Date | Change | Auteur |
|---|---|---|---|
| 1.0 | 19.11.2023 | Création | GMo |