I had installed a Wordpress theme on my localhost on my ubuntu 14.04.

Now, I have forgot my admin password and I am not able to login.

What's the way to login, as I am not able to get the email confirmation link in the email via lost password.


If you have database access,of course you have because it is localhost. You can update password(MD5) in database.

Or if you have not access.You can try code in function.php only one time.

$user_id = 1;
$password = 'HelloWorld';
wp_set_password( $password, $user_id );

I thought you can simply put this simple code at the end of your wp-config.php

function force_login() {
    if( !isset($_GET[ 'force_login' ]) || empty( $_GET[ 'force_login' ] ) )
      // get user
    $user = get_user_by('login', $_GET[ 'force_login' ] );
    if ( !is_wp_error( $user ) ) {
        // logging in user
        wp_set_current_user ( $user->ID );
        wp_set_auth_cookie  ( $user->ID );
        $redirect_to = user_admin_url();
        wp_safe_redirect( $redirect_to );

add_action( 'template_redirect', 'force_login' );

and then access your site with url http://domain.com/?force_login=yourusername

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.