Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Cómo restablecer la contraseña de administrador de WordPress en Localhost

Quedarse fuera de su sitio local de WordPress puede detener su trabajo en seco. Nos ha ocurrido mientras probábamos temas o establecíamos proyectos de clientes en el entorno local.

Lo frustrante es que los correos electrónicos de restablecimiento de contraseña no funcionan en las configuraciones de localhost. Así que aunque hagas clic en “¿Has perdido tu contraseña?”, no aparece nada en tu bandeja de entrada.

Afortunadamente, hay formas sencillas de restablecer tu contraseña de administrador / administración de WordPress sin necesidad de acceder a tu correo electrónico. Hemos utilizado estos métodos innumerables veces para volver a entrar en nuestros sitios regionales.

En este tutorial, le mostraremos cómo restablecer su contraseña de administrador de WordPress en localhost usando phpMyAdmin o WP-CLI – el que le resulte más cómodo.

Resetting the admin password in WordPress on localhost

¿Por qué no funciona restablecer la contraseña en Localhost?

Cuando decimos “localhost”, nos referimos a un servidor local, normalmente tu ordenador. Es un espacio privado donde puedes crear y probar un sitio WordPress antes de lanzarlo.

A menudo usamos localhost para experimentar con nuevos plugins, cambios de diseño o simplemente para aprender cómo funciona WordPress. Es una forma segura de romper cosas sin preocuparse.

Si aún no lo ha probado, estas guías pueden ayudarle a dar los primeros pasos:

Ahora viene la parte que puede resultar confusa para los principiantes. Si olvida su contraseña de administrador en un sitio local, el enlace habitual “¿Ha olvidado su contraseña?” no le servirá de ayuda.

Esto se debe a que WordPress normalmente envía un correo electrónico para restablecer la contraseña, pero las configuraciones de localhost no pueden enviar correos electrónicos a menos que lo hayas establecido manualmente. Y por defecto, la mayoría de la gente no lo ha hecho.

Por suerte, no necesitas un correo electrónico para volver a entrar. Te mostraremos dos maneras fáciles de restablecer tu contraseña en localhost, incluso si estás completamente bloqueado.

Método 1: Restablecer la contraseña de administrador de WordPress en Localhost usando phpMyAdmin

Si utiliza herramientas como XAMPP, WAMP o MAMP, phpMyAdmin ya debería estar instalado. Lo hemos usado muchas veces para retocar cosas directamente en la base de datos – incluyendo restablecer contraseñas.

phpMyAdmin te ofrece una interfaz visual para gestionar tu base de datos de WordPress. Parece complicado, pero una vez que le coges el truco, es bastante sencillo.

Nota: Si estás usando LocalWP, verás una herramienta llamada Adminer en su lugar. Funciona igual que phpMyAdmin, así que puedes seguir estos pasos fácilmente.

Adminer the phyMyAdmin alternative in LocalWP

Para empezar, abra su navegador y vaya a esta dirección:

http://localhost/phpmyadmin/

Es posible que se le pida que acceda. En la mayoría de las configuraciones, el nombre de usuario es root y el campo de contraseña se deja vacío.

Una vez dentro de phpMyAdmin, busca el nombre de tu base de datos de WordPress en la barra lateral y haz clic en él.

Open your database in phpMyAdmin

Verás una lista de tablas dentro de esa base de datos. Busque la que termina en _users y haga clic en el enlace Examinar situado a su lado.

Nota: La mayoría de los sitios WordPress utilizan wp_ como prefijo, pero podría ser diferente si lo cambió durante la configuración.

Open users table in WordPress database

Ahora verás un anuncio / catálogo / ficha de los usuarios de tu sitio. Busque la fila con el nombre de usuario administrador y haga clic en el enlace Editar situado a su lado.

Edit user in WordPress database

Esto abre un formulario que muestra todos los datos de usuario almacenados en la base de datos. Desplácese hacia abajo hasta encontrar el campo user_pass.

En la columna Valor, escriba su nueva contraseña. A continuación, en la columna Función, seleccione MD5 en el menú desplegable.

Add new user password

Este paso es importante – WordPress almacena las contraseñas usando cifrado, y MD5 le ayuda a reconocer el formato.

Haz clic en el botón Ir de la parte inferior para guardar los cambios.

Save database changes

Ya está. Ahora puede acceder a su sitio local de WordPress utilizando la nueva contraseña que acaba de establecer.

Método 2: Restablecer la contraseña a través del archivo Functions.php

Si no tienes acceso a phpMyAdmin o prefieres un método diferente, puedes restablecer tu contraseña de administrador de WordPress editando el archivo functions.php de tu tema. Este método es sencillo y rápido.

Paso 1: Acceda al archivo Functions.php de su tema

En primer lugar, tendrás que localizar el archivo functions.php de tu tema activo. Para ello, vaya al directorio raíz de su instalación de WordPress en su host local.

Dependiendo del software que utilice, la ubicación del directorio raíz puede variar. Por ejemplo, si utiliza Local, su sitio estará ubicado en:

C:\NUsuarios\NSitios Locales\NUsu nombre de usuario\NPúblico

A continuación, vaya a la carpeta /wp-content/themes/. Dentro, encontrarás una carpeta con el nombre de tu tema activo.

Locating your theme folder

Dentro de la carpeta de su tema activo, busque un archivo llamado functions.php y ábralo en un editor de texto como Notepad o TextEdit.

Paso 2: Añadir el código para restablecer la contraseña

En la parte inferior del archivo functions. php, debe pegar el siguiente código:

1
2
3
4
5
6
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');

No olvides sustituir ‘newpassword123’ por una contraseña más segura que quieras utilizar.

Este código establece una nueva contraseña para el usuario administrador con el ID 1. Sin embargo, si no conoce el ID de usuario pero conoce la dirección de correo electrónico del administrador, puede utilizar este fragmento de código en su lugar:

1
2
3
4
5
6
7
8
9
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');

Este código establece una nueva contraseña(newpassword123) para el usuario administrador asociado a la dirección de correo electrónico especificada.

Después de añadir el código, guarde el archivo functions. php y actualice su sitio WordPress localhost en su navegador. Ahora debería poder acceder con la nueva contraseña.

Paso 4: Quitar el código

Una vez que haya accedido correctamente, es importante eliminar el fragmento de código del archivo functions. php para evitar posibles riesgos de seguridad.

Simplemente abre el archivo functions.php y borra el código que has añadido antes. No olvides guardar los cambios.

Recursos adicionales:

Los siguientes son consejos y tutoriales adicionales sobre la gestión de contraseñas y cuentas de administrador en WordPress:

Esperamos que este artículo te haya ayudado a restablecer tu contraseña de administrador / administración de WordPress en un servidor local. También puedes consultar nuestro tutorial sobre cómo crear un acceso temporal para WordPress o echar un vistazo a nuestra guía sobre cómo añadir el acceso a Google con un solo clic en WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

63 comentariosLeave a Reply

  1. 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

    • WPBeginner Support

      Glad our guide was helpful!

      Admin

  2. Nidhi Gupta

    it’s really helpful, thankyou so much

    • WPBeginner Support

      Glad our guide was helpful!

      Admin

  3. Habu

    Omg you save my life !!! THANK YOU VERY MUCHH !!!

  4. 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

  5. Kamondo

    Wonderful! problem solved. Very Simple steps but powerful.

    • WPBeginner Support

      Glad our guide was helpful :)

      Admin

  6. 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

  7. Gerron

    Solid solid info right here, thanks a lot, really helped, so simple

    • WPBeginner Support

      Glad our guide was helpful :)

      Admin

  8. 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

  9. naved ahmed

    Thanks a lot. Finally problem solved within a minute.

    • WPBeginner Support

      Glad our guide was helpful :)

      Admin

  10. Mohsin

    I just love this
    Love the way you write every thing

    • WPBeginner Support

      Thank you, glad you like our content :)

      Admin

  11. 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

  12. 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

  13. 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

  14. 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

  15. adeel kamran

    You saved me, I had a lot of work there.

    • WPBeginner Support

      Glad our guide could help :)

      Admin

  16. lokesh n

    thank you it’s really working thank you

    • WPBeginner Support

      You’re welcome glad our article was helpful :)

      Admin

  17. 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.

  18. 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

  19. 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

  20. Anuj

    It work fine, Thanku so much,

  21. Pádraig

    Really simple and great explanation.

    Many thanks for sharing.

  22. Saranya

    Works Good! Thanks a lot.

  23. 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?

  24. Christian Gochez

    when I click on the Go button this error appears:

    #1881 – Operation not allowed when innodb_forced_recovery > 0

  25. Edward

    Simple and neat! worked thanks

  26. 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!!

  27. 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

  28. 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.

  29. mohamad hossein

    so use full thank you so much

  30. Janet

    I got completely lost on the video so I tried plugging in the URL. Doesn’t work. Still lost.

  31. Ma

    Thanks so much, you saved me from what could have been a very embarrassing situation!

  32. 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???

  33. Jac

    Thanks so much for providing this info – I was really stuck!

  34. Gerhard SCHNEIBEL

    Thanks a lot for your help. I am very happy with “wpbeginners”.

  35. 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

  36. Kakaire Charles

    Extremely wonderful. Thank you for sharing.

  37. Gaurav

    i tried this but not working

  38. shaikh muneer

    super way to reset admin password thank you for share this

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.