15-09-2021
This commit is contained in:
71
docs/MySQL/users.md
Normal file
71
docs/MySQL/users.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# Utilisateurs
|
||||
|
||||
|
||||
|
||||
### Voir tous les utilisateurs MySQL:
|
||||
|
||||
ainsi que les hosts auxquels ils ont le droit de se connecter.
|
||||
|
||||
```mysql
|
||||
MariaDB [(none)]> SELECT user,host from mysql.user;
|
||||
+-----------------+-----------+
|
||||
| User | Host |
|
||||
+-----------------+-----------+
|
||||
| adm_wp | localhost |
|
||||
| bruno | localhost |
|
||||
| mariadb.sys | localhost |
|
||||
| mysqlbackupuser | localhost |
|
||||
| newuser | localhost |
|
||||
| root | localhost |
|
||||
+-----------------+-----------+
|
||||
6 rows in set (0.001 sec)
|
||||
```
|
||||
|
||||
on affiche également les mots-de-passe.
|
||||
|
||||
```mysql
|
||||
MariaDB [(none)]> SELECT host,user,password FROM mysql.user;
|
||||
|
||||
# MySQL 5.7+
|
||||
MariaDB [(none)]> SELECT host,user,authentication_string FROM mysql.user;
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Créer un utilisateur:
|
||||
|
||||
`mysql> CREATE USER theuser;`
|
||||
|
||||
```mysql
|
||||
MariaDB [(none)]> CREATE USER 'theuser'@'localhost' IDENTIFIED BY 'the_password';
|
||||
```
|
||||
|
||||
Lui donner tous les droits:
|
||||
|
||||
```mysql
|
||||
MariaDB [(none)]> GRANT ALL PRIVILEGES ON * . * TO 'theuser'@'localhost';
|
||||
MariaDB [(none)]> FLUSH PRIVILEGES
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Supprimer un utilisateur:
|
||||
|
||||
`mysql> DROP USER theuser;`
|
||||
|
||||
```mysql
|
||||
MariaDB [(none)]> DROP USER 'theuser'@'localhost';
|
||||
Query OK, 0 rows affected (0.023 sec)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Renommer un utilisateur:
|
||||
|
||||
`mysql> RENAME USER theuser;`
|
||||
|
||||
```mysql
|
||||
MariaDB [(none)]> RENAME USER 'theuser'@'localhost' TO 'the_user'@'localhost';
|
||||
Query OK, 0 rows affected (0.038 sec)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user