Question: I have to reset my password direct through database for that I used query

UPDATE users SET pass = md5('NEWPASSWORD') WHERE name = 'admin'

but still I am not able to login.

Can you please tell me where I am going wrong?

Answer: 
With drupal 7, password are no more encrypted through md5.

There are several way to reset a password in drupal7.

**Using drush** : 

```
drush upwd admin --password="newpassword"

```

**Without drush, if you have a cli access to the server :** 

```
cd <drupal root directory>
php scripts/password-hash.sh 'myPassword'

```

Now copy the resultant hash and paste it into the query:

```
update users set name='admin', pass='pasted_big_hash_from_above' where uid=1;

```

**If you are working on a remote environment** on which you cannot connect, you can put this specified code in a file such as password.php such as this one:

```
<?php
if (isset($_GET['p'])) {
  require_once dirname(__FILE__) . '/includes/bootstrap.inc';
  require_once dirname(__FILE__) . '/includes/password.inc';
  print _password_crypt('sha512', $_GET['p'], _password_generate_salt(DRUPAL_HASH_COUNT));
  exit();
}
print "No password to hash.";

```

And then hit your site using: <http://domain.tld/password.php?p=MyPassword>. The hash will appear on your browser's tab.  

 Don't forget to remove it once you done it.
Are you locked out of your account? If you've got DB access then try clearing out the "flood" table.