Non mi ricordo più la password del server MySQL

Esiste una modalità semplice per recuperare la password del server MySQL se non la si ha o non la si ricorda:

1 – Stoppare MySQL

# /etc/init.d/mysql stop

2 – Avviare mysql senza le GRANT TABLES

# /usr/bin/mysqld_safe –skip-grant-tables

3 – Accedere alla tabella mysql

# mysql -u root mysql

4 – Cambiare la password

mysql> UPDATE user SET Password=PASSWORD(‘newpassword’) WHERE User=’root’;mysql> FLUSH PRIVILEGES;

5 – riavviare MySQL normalmente/etc/init.d/mysql restart

6 – verificare la nuova password con # mysqlshow -p’newpassword’