mercredi 30 janvier 2008

MySQL Password Recovery

Bon alors... je sais, je sais on peut trouver ca partout.
Mais j'en ai justement marre de chercher partout !

Donc voici comment redefinir le mot de passe root de mysql sous GNU/Linux :
$ /etc/init.d/mysql stop
$ mysqld --skip-grant-tables &
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1Server version: 5.0.38-Ubuntu_0ubuntu1.1-log
Ubuntu 7.04 distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> UPDATE mysql.user SET Password=PASSWORD('mon_mot2passe')
WHERE User='root';
Query OK, 3 rows affected (0.05 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

mysql> exit
Bye

$ killall mysqld
$/etc/init.d/mysql start


Et voila... :)
Les messages et la façon de démarrer/arrêter mysql seront evidemment different selon votre serveur.
Vous devez bien entendu remplacer "mon_mot2passe" par le mot de passe que vous souhaitez attribuer à "root".