Reset password in Drupal 6 & 7 from database

For drupal6

UPDATE users SET name='admin', pass=md5('drupal') WHERE uid = 1;

For drupal7
define(‘DRUPAL_ROOT’, getcwd());
require_once DRUPAL_ROOT . ‘/includes/bootstrap.inc’;
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once ‘includes/password.inc’;
$pwd = user_hash_password(‘NewPassword‘);

UPDATE users SET name=’admin’, pass=’$pwd’ WHERE uid = 1;