Tutorial passo passo per imparare a recuperare la password di root di un server SQL.
L'utente più importante di un server MySQL è sicuramente l'utente "root". Questo utente ha tutto privilegi amministrativi per i database (MySQL databases).
Nel caso in cui non sapessi più qual è la password dell'utente root di MySQL, dovrai seguire alcuni semplici passaggi per reimpostare questa password.
Il tutorial è fatto per un server MySQL installato sul sistema operativo CentOS, ma il processo è lo stesso per le altre distribuzioni Linux.
Come recuperare la password per l'utente root di un server SQL
Per recuperare la password per l'utente root di un server SQL, il metodo più semplice è by SSH (Secure Shell).
1. Accediamo con l'utente "root” al sistema su cui si trova il server MySQL. (l'utente root del sistema, non del server MySQL). Accedi direttamente dalla console o da remoto tramite connessione SSH (con stucco dai sistemi Windows).
2. Interrompere il processo / MySQL.
service mysqld stop
o
/etc/init.d/mysqld stop
Il risultato sarà:
Stopping MySQL: [ OK ]
3. Avviamo il server MySQL con l'opzione "--skip-grant-tables
". Avvio del server MySQL/daemon processo senza password.
mysqld_safe --skip-grant-tables &
L'output dopo la riga di comando sopra:
[1] 3041
[root@server ~]# Starting mysqld daemon with databases from /var/lib/mysql
4. Ci colleghiamo al server mysql con l'utente "root", utilizzando il comando:
mysql -u root
Il risultato:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql>
5. Selezionare il database mysql e impostare la nuova password per l'utente "root".
use mysql;
update user set password=PASSWORD("New_Password") where User='root';
flush privileges;
quit
Risultati dai comandi precedenti:
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("123456") where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
[root@server ~]#
6. Arrestiamo e riavviamo il servizio / server MySQL
service mysqld stop
service mysqld start
Risultato:
Starting MySQL: [ OK ]
L'immagine qui sotto mostra tutto processo di reimpostazione della password dell'utente "root” del server MySQL.
Ora siamo in grado di connettersi a MySQL (da phpMyAdmin es.) con l'utente "root", utilizzando la nuova password sopra impostata.
Tutorial testato CentOS 5.6 con MySQL Ver 14.12 Distrib 5.0.77, per redhat-linux-gnu (i686) usando readline 5.1.