Retrouver l’accès à Mysql

Suite au fameux message : « Access denied for user ‘root’@’localhost’ (using password: YES) » auquel je viens d’être confronté, voici ce qui m’a permis de me sauver de la perte de mes bases de données.

# service mysql stop
Shutting down MySQL..
# mysqld_safe --skip-grant-tables --skip-networking &
[1] 4983
# Starting mysqld daemon with databases from /var/lib/mysql

# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.21-log

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

mysql> update user set password=password('aaaaaaaa') where user="root" and host="localhost";
Query OK, 0 rows affected (0,00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> exit
Bye
# mysqladmin shutdown
STOPPING server from pid file /var/lib/mysql/debian.pid
030811 14:38:40  mysqld ended

[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking
# service mysql start
Starting MySQL
# mysql -u root -p

J’espère que ça vous rendra service si vous êtes dans le même cas de figure 🙂