« Changer le mot de passe mysql » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
m (<syntaxhighlight lang="mysql" line="line">) |
||
Ligne 16 : | Ligne 16 : | ||
Dans une autre console, accédez à MySql (sans mot de passe...) | Dans une autre console, accédez à MySql (sans mot de passe...) | ||
<syntaxhighlight lang="mysql" line="line"> | |||
# mysql -u root | |||
Welcome to the MySQL monitor. Commands end with ; or \g. | |||
Your MySQL connection id is 1 | |||
Server version: 5.1.49-3 (Debian) | |||
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |||
This software comes with ABSOLUTELY NO WARRANTY. This is free software, | |||
and you are welcome to modify and redistribute it under the GPL v2 license | |||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |||
mysql> FLUSH PRIVILEGES; | |||
Query OK, 0 rows affected (0.00 sec) | |||
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('votre_nouveau_mot_de_passe'); | |||
Query OK, 0 rows affected (0.00 sec) | |||
mysql> FLUSH PRIVILEGES; | |||
Query OK, 0 rows affected (0.00 sec) | |||
mysql> exit | |||
Bye | |||
</syntaxhighlight> | |||
Redémarrez MySql en mode "normal": | Redémarrez MySql en mode "normal": | ||
Ligne 45 : | Ligne 46 : | ||
Faites un test avec le nouveau mot de passe: | Faites un test avec le nouveau mot de passe: | ||
<syntaxhighlight lang="mysql" line="line"> | |||
# mysql -u root -p | |||
Enter password: | |||
Welcome to the MySQL monitor. Commands end with ; or \g. | |||
Your MySQL connection id is 88 | |||
Server version: 5.1.49-3 (Debian) | |||
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |||
This software comes with ABSOLUTELY NO WARRANTY. This is free software, | |||
and you are welcome to modify and redistribute it under the GPL v2 license | |||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |||
mysql> exit | |||
Bye | |||
</syntaxhighlight> | |||
Voilà! | Voilà! |
Dernière version du 20 février 2017 à 07:06
Changer le mot de passe Mysql
Il peut arriver d'avoir à changer le mot de passe "root" de Mysql. Voici la méthode:
Stoppez MySql
# /etc/init.d/mysql stop
Démarrez ensuite MySql avec les options suivantes: (Permet de démarrer sans prendre en compte les droits et sans écouter le réseau) L'option --skip-networking est très importante du point de vue de la sécurité, elle permet d'éviter à un petit malin de prendre le controle de MySql - sans mot de passe - pendant votre petite manip...)
# /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Dans une autre console, accédez à MySql (sans mot de passe...)
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.49-3 (Debian)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('votre_nouveau_mot_de_passe');
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
Redémarrez MySql en mode "normal":
# service mysql restart
Faites un test avec le nouveau mot de passe:
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 88
Server version: 5.1.49-3 (Debian)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
Voilà!
Sources
- (fr) changer le mot de passe de mysql... je craque
- (fr) Réinitialisation du mot de passe root de MySql
- (fr) Changer le mot de passe de root sur Mysql
Lol 22 janvier 2012 à 06:38 (CET)