Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
linux:mariadb [10-09-2017 15:59] – créée edmc73 | linux:mariadb [04-04-2025 16:19] (Version actuelle) – edmc73 | ||
---|---|---|---|
Ligne 19: | Ligne 19: | ||
</ | </ | ||
+ | |||
+ | ===== Commandes ===== | ||
+ | |||
+ | Créer un utilisateur | ||
+ | CREATE USER ' | ||
+ | |||
+ | Voir la liste des users | ||
+ | |||
+ | < | ||
+ | mysql> select host,user from mysql.user; | ||
+ | +-----------+------------------+ | ||
+ | | host | user | | ||
+ | +-----------+------------------+ | ||
+ | | % | toto | | ||
+ | | 127.0.0.1 | root | | ||
+ | | ::1 | root | | ||
+ | | debian | ||
+ | | localhost | api | | ||
+ | | localhost | debian-sys-maint | | ||
+ | | localhost | root | | ||
+ | +-----------+------------------+ | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | Voir les privilèges | ||
+ | |||
+ | < | ||
+ | mysql> SELECT * FROM information_schema.user_privileges; | ||
+ | +--------------------------------+---------------+-------------------------+--------------+ | ||
+ | | GRANTEE | ||
+ | +--------------------------------+---------------+-------------------------+--------------+ | ||
+ | | ' | ||
+ | | ' | ||
+ | | ' | ||
+ | | ' | ||
+ | | ' | ||
+ | | ' | ||
+ | | ' | ||
+ | | ' | ||
+ | | ' | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | mysql> show grants for ' | ||
+ | +----------------------------------------------------------------------------------------------------------------------------------------+ | ||
+ | | Grants for root@localhost | ||
+ | +----------------------------------------------------------------------------------------------------------------------------------------+ | ||
+ | | GRANT ALL PRIVILEGES ON *.* TO ' | ||
+ | | GRANT PROXY ON '' | ||
+ | +----------------------------------------------------------------------------------------------------------------------------------------+ | ||
+ | </ | ||
+ | |||
+ | Penser aussi à modifier le fichier **/ | ||
+ | < | ||
+ | # Automatically generated for Debian scripts. DO NOT TOUCH! | ||
+ | [client] | ||
+ | host = localhost | ||
+ | user = root | ||
+ | password = XXXXXXXXXX | ||
+ | socket | ||
+ | [mysql_upgrade] | ||
+ | host = localhost | ||
+ | user = root | ||
+ | password = XXXXXXXXXX | ||
+ | socket | ||
+ | basedir | ||
+ | </ | ||
+ | |||
+ | Ca permettra par exemple à logrotate de générer des erreurs du type | ||
+ | < | ||
+ | # | ||
+ | error: ' | ||
+ | error: error running shared postrotate script for '/ | ||
+ | </ | ||
+ | |||
+ | Vérifiez le bon fonctionnement avec la commande | ||
+ | < | ||
+ | # mysqladmin --defaults-file=/ | ||
+ | +----------+-------------+-----------+----+---------+------+--------------------------+------------------+----------+ | ||
+ | | Id | User | Host | db | Command | Time | State | Info | Progress | | ||
+ | +----------+-------------+-----------+----+---------+------+--------------------------+------------------+----------+ | ||
+ | | 1 | system user | | ||
+ | | 2 | system user | | ||
+ | | 3 | system user | | ||
+ | | 4 | system user | | ||
+ | | 5 | system user | | ||
+ | | 14507011 | root | localhost | | Query | 0 | Init | show processlist | 0.000 | | ||
+ | +----------+-------------+-----------+----+---------+------+--------------------------+------------------+----------+ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ===== mot de passe root perdu ===== | ||
+ | Si vous avez perdu votre mot de passe root, pas de panic | ||
+ | |||
+ | source: https:// | ||
+ | |||
+ | Stoppez mysql ou mariadb | ||
+ | systemctl stop mysql | ||
+ | |||
+ | Démarrez mysql sans permissions (accès total à tout sans mot de passe !! ATTENTION !!) | ||
+ | mysqld_safe --skip-grant-tables & | ||
+ | |||
+ | Connectez vous à mysql | ||
+ | mysql -u root | ||
+ | |||
+ | Modifiez le mot de passe root | ||
+ | mysql> ALTER USER ' | ||
+ | mysql> FLUSH PRIVILEGES; | ||
+ | |||
+ | Si ça ne marche pas, essayez | ||
+ | mysql> UPDATE mysql.user SET authentication_string = PASSWORD(' | ||
+ | mysql> WHERE User = ' | ||
+ | mysql> FLUSH PRIVILEGES; | ||
+ | |||
+ | Pour les anciennes versions, essayez | ||
+ | mysql> SET PASSWORD FOR ' | ||
+ | mysql> FLUSH PRIVILEGES; | ||
+ | |||
+ | Ensuite, quittez mysql et stoppez le via la commande | ||
+ | mysqladmin -u root -p shutdown | ||
+ | |||
+ | Démarrez ensuite mysql normalement | ||
+ | systemctl start mysql | ||
+ | ou | ||
+ | systemctl start mariadb | ||
+ | |||
+ | vérifiez que tout est ok | ||
+ | mysql -u root -p | ||
+ |