Se connecter a Mariadb depuis un autre utilisateur |
Article original Publié le : 06 septembre 2020 Mise a jour le : – |
Vérifier les comptes utilisateurs sur le SGDB
1 |
MariaDB [(none)]> USE mysql; |
1 |
MariaDB [(none)]> SELECT user, host, plugin FROM mysql.user; |
1 2 3 4 5 |
+------+-----------+-------------+ | user | host | plugin | +------+-----------+-------------+ | root | localhost | unix_socket | +------+-----------+-------------+ |
Créer un compte utilisateur système et ajouter lui les privilèges et droits nécessaires
1 |
MariaDB [(none)]> CREATE USER '<strong>bef</strong>'@'localhost' IDENTIFIED BY ''; |
1 |
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO '<strong>bef</strong>'@'localhost'; |
1 |
MariaDB [(none)]> UPDATE user SET plugin='auth_socket' WHERE User='<strong>bef</strong>'; |
1 |
MariaDB [(none)]> UPDATE mysql.user SET plugin = '' WHERE plugin = 'unix_socket'; |
1 |
MariaDB [(none)]> FLUSH PRIVILEGES; |
Revérifier les utilisateurs
1 |
MariaDB [(none)]> SELECT user, host, plugin FROM mysql.user; |
1 2 3 4 5 6 |
+------+-----------+-------------+ | user | host | plugin | +------+-----------+-------------+ | root | localhost | unix_socket | | bef | localhost | auth_socket | +------+-----------+-------------+ |
1 |
MariaDB [(none)]> exit; |
Redémarrer le service et tester une connexion depuis l’utilisateur système et root
1 |
$ sudo systemctl restart mysql.service |
https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost
https://stackoverflow.com/questions/43439111/mariadb-warning-rootlocalhost-has-both-the-password-will-be-ignored