Bloccare il proprio sito WordPress in locale può bloccare il lavoro. Ci è capitato mentre testavamo temi o impostavamo progetti di clienti sull’ambiente locale.
La parte frustrante è che le email di reimposta della password non funzionano su configurazioni localhost. Quindi, anche se si fa clic su “Hai perso la password?”, non viene visualizzato nulla nella casella di posta.
Fortunatamente, esistono modi semplici per reimpostare la password di amministrazione di WordPress senza dover accedere all’email. Abbiamo usato questi metodi innumerevoli volte per rientrare nei nostri siti locali.
In questo tutorial vi mostreremo come reimpostare la password di amministrazione di WordPress su localhost utilizzando phpMyAdmin o WP-CLI, a seconda di quale sia più comodo per voi.

Perché la reimpostazione della password non funziona su Localhost
Quando si parla di “localhost”, chi siamo si riferisce a un server locale, di solito il vostro computer. Si tratta di uno spazio privato dove è possibile costruire e testare un sito WordPress prima di andare in onda.
Spesso utilizziamo localhost per sperimentare nuovi plugin, modifiche al design o semplicemente per imparare il funzionamento di WordPress. È un modo sicuro per rompere le cose senza preoccuparsi.
Se non avete ancora provato, queste guide possono aiutarvi a iniziare:
Ecco la parte che può confondere i principianti. Se si dimentica la password di amministrazione su un sito locale, il normale link “Hai perso la password?” non sarà d’aiuto.
Questo perché WordPress normalmente invia un’email di reimposta della password, ma le impostazioni di localhost non possono inviare email a meno che non siano state configurate manualmente. E di default, la maggior parte delle persone non lo fa.
Fortunatamente, non è necessaria un’email per rientrare. Vi mostriamo due modi semplici per reimpostare la password su localhost, anche se siete completamente bloccati.
Metodo 1: reimposta la password dell’amministratore di WordPress su localhost usando phpMyAdmin
Se si utilizzano strumenti come XAMPP, WAMP o MAMP, phpMyAdmin dovrebbe essere già installato. Lo abbiamo usato molte volte per modificare le cose direttamente nel database, compresa la reimposta delle password.
phpMyAdmin offre un’interfaccia visiva per gestire il database di WordPress. Sembra complicato, ma una volta che ci si prende la mano, è piuttosto semplice.
Nota: se si utilizza LocalWP, si vedrà invece uno strumento chiamato Adminer. Funziona proprio come phpMyAdmin, quindi potete seguire facilmente questi passaggi.

Per iniziare, aprite il vostro browser e indirizzatevi a questo indirizzo:
http://localhost/phpmyadmin/
Potrebbe essere richiesto di effettuare l’accesso. Nella maggior parte delle configurazioni, il nome utente è root e il campo della password è lasciato vuoto.
Una volta entrati in phpMyAdmin, cercate il nome del vostro database WordPress nella barra laterale e cliccateci sopra.

Verrà visualizzato un elenco di tabelle all’interno del database. Individuare quella che termina con _users
e fare clic sul link Sfoglia accanto ad essa.
Nota: la maggior parte dei siti WordPress usa wp_
come prefisso, ma potrebbe essere diverso se è stato modificato durante la configurazione.

Ora verrà visualizzato un elenco di utenti sul sito. Individuare la riga con il nome utente dell’amministratore e fare clic sul link Modifica accanto ad essa.

Si apre un modulo che mostra tutti i dati dell’utente memorizzati nel database. Scorrere verso il basso fino a trovare il campo user_pass.
Nella colonna Valore, digitare la nuova password. Nella colonna Funzione, selezionare MD5 dal menu a discesa.

Questo passaggio è importante: WordPress memorizza le password utilizzando la crittografia e MD5 lo aiuta a riconoscere il formato.
Fare clic sul pulsante Vai in basso per salvare le modifiche.

Ecco fatto! Ora potete accedere al vostro sito WordPress locale utilizzando la nuova password appena impostata.
Metodo 2: reimposta la password tramite il file Functions.php
Se non avete accesso a phpMyAdmin o preferite un approccio diverso, potete reimpostare la password di amministrazione di WordPress modificando il file functions.php
del tema. Questo metodo è semplice e può essere eseguito rapidamente.
Fase 1: accedere al file Functions.php del tema
Per prima cosa, è necessario individuare il file functions.php del tema attivato. A tale scopo, navigare nella directory principale dell’installazione di WordPress sull’host locale.
A seconda del software utilizzato, la posizione della directory principale può variare. Ad esempio, se si utilizza Local, il sito si troverà in:
C:´Utente´Nomeutente´Siti locali´Nomeutente´apparente´pubblico´.
Quindi, accedere alla cartella /wp-content/themes/
. Al suo interno troverete una cartella con il nome del tema attivato.

Nella cartella del tema attivato, cercare un file chiamato functions.php
e aprirlo in un editor di testo come Notepad o TextEdit.
Passo 2: Aggiungere il codice per reimpostare la password
In fondo al file functions.php
, è necessario incollare il seguente codice:
function reset_admin_password() {
$user_id = 1; // ID of the admin user
$new_password = 'newpassword123'; // Your new password
wp_set_password($new_password, $user_id);
}
add_action('init', 'reset_admin_password');
Non dimenticate di sostituire “newpassword123” con una password più forte che volete usare.
Questo codice imposta una nuova password per l’utente admin con ID 1. Tuttavia, se non si conosce l’ID dell’utente ma si conosce l’indirizzo email dell’admin, si può usare questo frammento di codice:
function reset_admin_password_by_email() {
$user_email = 'admin@example.com'; // Admin user's email address
$user = get_user_by('email', $user_email);
if ($user) {
$new_password = 'newpassword123'; // Your new password
wp_set_password($new_password, $user->ID);
}
}
add_action('init', 'reset_admin_password_by_email');
Questo codice imposta una nuova password(newpassword123
) per l’utente admin associato all’indirizzo email specificato.
Dopo aver aggiunto il codice, salvare il file functions.php
e aggiornare il sito WordPress dell’host locale nel browser. Ora dovreste essere in grado di effettuare l’accesso utilizzando la nuova password.
Passo 4: rimuovere il codice
Una volta effettuato l’accesso, importa rimuovere il frammento di codice dal file functions.php
per evitare potenziali rischi per la sicurezza.
È sufficiente aprire il file functions.php
ed eliminare il codice aggiunto in precedenza. Non dimenticate di salvare le modifiche.
Risorse bonus:
Di seguito sono riportati ulteriori suggerimenti e tutorial sulla gestione delle password e degli account di amministrazione in WordPress:
- Come aggiungere un utente amministratore al database di WordPress tramite MySQL
- Come aggiungere un utente amministratore in WordPress usando l’FTP (tutorial facile)
- Guida per i principianti alla ricezione di email di WordPress da Localhost con SMTP
- Come gestire le password in modo facile e sicuro (Guida per principianti)
- Come proteggere con password la directory dell’amministrazione di WordPress (wp-admin)
Speriamo che questo articolo vi abbia aiutato a reimpostare la password di amministrazione di WordPress su un server locale. Potreste anche consultare il nostro tutorial sulla creazione di un accesso temporaneo per WordPress o dare un’occhiata alla nostra guida su come aggiungere un accesso a Google con un clic in WordPress.
Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.
Hafiz Muhammad Ansar
Very nice blog for WordPress help. I recommend for beginners to use this platform. Thankful!
WPBeginner Support
Glad you found our article helpful!
Admin
Abdullah
Amazing, it worked
WPBeginner Support
Glad our guide was helpful!
Admin
Nidhi Gupta
it’s really helpful, thankyou so much
WPBeginner Support
Glad our guide was helpful!
Admin
Habu
Omg you save my life !!! THANK YOU VERY MUCHH !!!
Jahir
I can not log in now same process…any updates?
WPBeginner Support
The most common issue would be if you did not set the function to MD5 or click go to apply the changes, you would want to ensure you have done that correctly.
Admin
Kamondo
Wonderful! problem solved. Very Simple steps but powerful.
WPBeginner Support
Glad our guide was helpful
Admin
Joe
I’m encoutering this problem now after installing the 2nd WordPress on MAMP. This article is very to the point and I’ll try it tomorrow!
WPBeginner Support
We hope the guide helps
Admin
Gerron
Solid solid info right here, thanks a lot, really helped, so simple
WPBeginner Support
Glad our guide was helpful
Admin
Odineks
Thank you so much. I always find solutions to every of my WP problems here.
I kept having problems with the login page on the frontend not recognizing my new password, I didn’t realize there is a function to pass that message to myPHPadmin.
WPBeginner Support
Glad our guide was helpful
Admin
naved ahmed
Thanks a lot. Finally problem solved within a minute.
WPBeginner Support
Glad our guide was helpful
Admin
Mohsin
I just love this
Love the way you write every thing
WPBeginner Support
Thank you, glad you like our content
Admin
Jen
I tried this and while I was in there also attempted to change my username, which I realize was probably my mistake… but now I can’t log in at all. Is there a way to undo what I’ve done?
WPBeginner Support
You would need to follow the steps in the article and that would bring you back to where you could edit, you should also be able to use your email as an alternative
Admin
Justina
Your Blog is always so full of rich articles. Thanks so much. was stuck for a while because I skip the MD5 option. You are a lifesaver.
WPBeginner Support
Glad our guide could be helpful
Admin
Sarah
Thank you SO MUCH for this! You saved me so many more hours of tinkering with trying to figure out how to log in!!
WPBeginner Support
Glad we were able to help
Admin
David
Thank you ever so much! Normally, I keep this stuff handy; but in this case, I did could not find where I wrote the information down.
You saved a total re-work of a site I was planning.
WPBeginner Support
Glad our guide could be helpful
Admin
adeel kamran
You saved me, I had a lot of work there.
WPBeginner Support
Glad our guide could help
Admin
lokesh n
thank you it’s really working thank you
WPBeginner Support
You’re welcome glad our article was helpful
Admin
Vivek
Hi,
When I reset My password through link then what fileds affected in Database and in which table.
Kindly share this information i am waiting for your response.
WPBeginner Support
For understanding the database you would want to take a look at our article here: https://www.wpbeginner.com/beginners-guide/beginners-guide-to-wordpress-database-management-with-phpmyadmin/
Admin
Adnan Khan
After half an hour of search i just found my help from this site, which solves my problem in no time,
thanks a lot
keep it up guys
WPBeginner Support
You’re welcome, glad our guides can be helpful
Admin
Tenasu Mensah
thanks a lot, kudos to you guys keep the good work doing,you guys are doing great job
WPBeginner Support
Glad our guide could help
Admin
Anuj
It work fine, Thanku so much,
Pádraig
Really simple and great explanation.
Many thanks for sharing.
Saranya
Works Good! Thanks a lot.
Patr
Hello,
I type a new password , click continue and it does not keep the password, it shows a long string of numbers and letters. If I use this , still cannot log in. It looks simple on the video but does not work for me. Thank you.
I looked everywhere on the internet, no solution worling.
Jason
Same problem here. Did you find a solution? Is there any chance of being hacked?
Christian Gochez
when I click on the Go button this error appears:
#1881 – Operation not allowed when innodb_forced_recovery > 0
Edward
Simple and neat! worked thanks
Handel
I started to just reinstall wordpress, but then decided to do a google search, and there was GOOD OLD RELIABLE WpBeginner.com
Thanks a million!!
Sheriff
very effective… kudos
Icholia
Hello
THANKS, Wow there is no other place that you can get well explained information like this , i have been suffering but now i just followed your tutorial and it is a game changer i love you guys and i will always learn from you guys once again thanks
CJ
Thank you! For those who can’t make it work, remember to use the “MD5” function when changing the password. I almost skipped that part and was stuck for a few minutes.
mohamad hossein
so use full thank you so much
Janet
I got completely lost on the video so I tried plugging in the URL. Doesn’t work. Still lost.
Ma
Thanks so much, you saved me from what could have been a very embarrassing situation!
James
I change the password, username, userlogin and nickname not I cant login. Any advice?
suganya
i can’t able to login .because it’s shows me like email is not registered .so what can i do???
Jac
Thanks so much for providing this info – I was really stuck!
Gerhard SCHNEIBEL
Thanks a lot for your help. I am very happy with “wpbeginners”.
Renu
it worked.. thanks a ton..
Anthony
Hi…
I am so thankful for such great information you provide. I have bookmarked your site a while back.
I have been working on a site in wordpress using xampp on the Apache local server. Just recently, I am not able to login on the admin page. I have managed to create a user name and password that works on about 95% of all sites requiring me to register. I also created a file that lists all my login info for everywhere I need to login, including the WP admin login page, IF I ever forget that info.
I have read this page (https://www.wpbeginner.com/wp-tutorials/how-to-reset-wordpress-admin-password-on-localhost/) and watched the video, also. The only problem is that when I click on the wp_users in phpMyadmin, I get this error- ‘#1932 – Table ‘bitnami_wordpress.wp_users’ doesn’t exist in engine.’
Am I reduced to re-installing WordPress, or is there another way around it?
I have tried restoring my computer (using system restore) to various past restore points, but with no luck. Can you help me with this?
I would be so thankful!!! I have put months of work into designing a site to launch, and I HAVE exported everything to a file quite a few times using WordPress import plugin (something like that).
Could you provide a solution?
Thank you so much…
Anthony
WPBeginner Support
Hi Anthony,
you can also add an admin user by adding code to your current WordPress theme’s admin file.
Admin
Kakaire Charles
Extremely wonderful. Thank you for sharing.
Gaurav
i tried this but not working
shaikh muneer
super way to reset admin password thank you for share this