2021-07-30 16:23:58 +02:00
|
|
|
---
|
|
|
|
categories: databases
|
2021-07-30 16:37:41 +02:00
|
|
|
title: MySQL - Gestion des utilisateurs
|
|
|
|
format: Markdown
|
2021-07-30 16:23:58 +02:00
|
|
|
...
|
|
|
|
|
2021-07-30 16:37:41 +02:00
|
|
|
### Obtenir la liste des utilisateurs
|
2021-07-30 16:23:58 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
mysql> SELECT User, Host from mysql.user;
|
|
|
|
```
|
|
|
|
|
2021-07-30 16:37:41 +02:00
|
|
|
### Créer un nouvel utilisateur
|
2021-07-30 16:23:58 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
mysql> CREATE USER `<user>`@`<host>` IDENTIFIED BY `<password>`;
|
|
|
|
```
|
|
|
|
|
2021-07-30 16:37:41 +02:00
|
|
|
### Affecter des droits à un utilisateur
|
2021-07-30 16:23:58 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
mysql> GRANT ALL PRIVILEGES ON <database>.* TO `<user>`@`<host>` IDENTIFIED BY `<password>`;
|
|
|
|
mysql> FLUSH PRIVILEGES;
|
|
|
|
```
|
|
|
|
|
2021-07-30 16:37:41 +02:00
|
|
|
### Vérifier les droits d'un utilisateur
|
2021-07-30 16:23:58 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
mysql> SHOW GRANTS FOR `<user>`@`<host>`;
|
|
|
|
```
|