MySQL Root Password Recovery

Seguono le istruzioni per resettare una password di root di mysql:
# stoppare mysqld
#killall mysqld

# lanciare mysqld con l'opzione skip-grant-tables, che evita di caricare le tabelle di sistema (tra cui anche quella degli accessi) fornendo libero accesso al servizio mysqld
# /usr/libexec/mysqld -Sg --user=root &

/usr/libexec/mysqld: ready for connections

# entrare in modalità client
# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.56

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

#collegarsi al db mysql e inserire la query di update di cambio password
mysql> USE mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> UPDATE user
    -> SET password=password("mianuovapassword")
    -> WHERE user="root";

Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

Privacy Policy