Search code examples
authenticationdrupalpasswords

Drupal 7 reset password


Hello sorry if this question is duplicate but unfortunately I couldn't find answer I need. I have a problem with a Drupal 7 login, I forgot the admin password and I can't open the reset password page so I tried through the PHPmyAdmin to make changes directly on database and I used this query:

UPDATE users SET pass='$S$Do7UQjqtEELNccdi92eCXcVJ2KnwUeHrSbK3YhFm8oR3lRJQbMB2' WHERE uid = 1;

and it successfully changed my password into database, but I still can't log in to website...is there any advice for me what could be a problem?

Thanks


Solution

  • In your index, you can write this code. Execute your web page. .

    define('DRUPAL_ROOT', getcwd());
    
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    
    
    require('includes/password.inc');
    
    echo "Now, execute this SQL<br><br> UPDATE users SET pass='".user_hash_password('mypassword')."' WHERE uid = 1;"; 
    die();
    menu_execute_active_handler();
    

    You can also use drush

    drush upwd admin --password=mypassword
    

    More info: https://www.drupal.org/forum/support/post-installation/2010-12-08/reset-admin-password-in-drupal-7