Sunday, February 8, 2015

Reset Magento admin password

Solution 1:

UPDATE admin_user SET password=CONCAT(MD5('qXpassword'), ':qX') WHERE username='admin';

Note: 'qX' would be changed to whatever you want it to be and same goes for 'password'.

Note: just to clarify a bit more: qX will be the salt, and password will be the final password.

Note: It's important to note that the hash length has increased between version 1.8 and 1.9 in CE (presumable 1.3 to 1.4 in EE) from 2 characters (as in the above example) to 32 characters.

http://stackoverflow.com/questions/16983227/after-installing-magento-in-my-local-machine-i-forgot-admin-password

Solution 2:
<?php
require_once '/www/magento1.9.1/app/Mage.php';
Mage::app();

$username = 'admin';
$password = 'admin1234';

updateAdminPassword($username, $password);

function updateAdminPassword($username, $password) {
  ## For magento1.8 and magento1.9
  $_HASH_SALT_LENGTH = 32;

  #Generate admin password
  $adminPass = Mage::helper('core')->getHash($password, $_HASH_SALT_LENGTH);

  ## And reset password field in "admin_user" table
  $conn = Mage::getSingleton('core/resource')->getConnection('core_write');

  $sql = "UPDATE admin_user SET password='" . $adminPass . "' WHERE username='" . $username . "' ";
  $rsCount = $conn->exec($sql);
  echo 'Affected rows: ' . $rsCount . "\n";
}
?>

Solution 3:

UPDATE admin_user SET password = MD5('MyPassword') WHERE username = 'MyUsername';

No comments: