Unable to successfully update WordPress admin password via MySql command line

Solution:

First of all: don’t touch this line define('DB_PASSWORD','some_password');. It’s not users password, it’s password to connect your mysql server.

The error you got Error Establishing a Database Connection occurred because of changing constantabove.

From wordpress codex sql command:

UPDATE (name-of-table-you-found) SET user_pass = MD5('(new-password)') WHERE ID = (id#-of-account-you-are-reseting-password-for);

So, your command will be:

//if your wordpress db tables prefix is `wp_`, then.
UPDATE wp_users SET user_pass = md5('myNewPassword') where id = 1;  

If database table prefix is something else, then run command like:

UPDATE yourWebsitePrefix_users SET user_pass = md5('myNewPassword') where id = 1;  

Also, make sure, that the password you’re trying to change belong to the user with id=1. If your user id is, for ex. 27, then run this:

UPDATE wp_users SET user_pass = md5('myNewPassword') where id = 27;