Utilisateurs¶
Voir tous les utilisateurs MySQL:¶
ainsi que les hosts auxquels ils ont le droit de se connecter.
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.
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;
MariaDB [(none)]> CREATE USER 'theuser'@'localhost' IDENTIFIED BY 'the_password';
Lui donner tous les droits:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON * . * TO 'theuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES
Supprimer un utilisateur:¶
mysql> DROP USER theuser;
MariaDB [(none)]> DROP USER 'theuser'@'localhost';
Query OK, 0 rows affected (0.023 sec)
Renommer un utilisateur:¶
mysql> RENAME USER theuser;
MariaDB [(none)]> RENAME USER 'theuser'@'localhost' TO 'the_user'@'localhost';
Query OK, 0 rows affected (0.038 sec)
Dernière mise à jour:
September 15, 2021