After entering the wrong password Magento has locked my admin account, How can I unlock this using database?

If there is another way of unlocking admin account please tell me. My Magento version is

4 Answers 4


This is the SQL way of unlocking a Magento admin account:

UPDATE admin_user 
SET failures_num=0, first_failure=NULL, lock_expires=NULL
WHERE username='<username>';

Replace the <username> with the target account's username.


Select the corresponding database from the drop down menu on the left side.

After that click on the SQL tab in order to be able to execute the following MySQL query and use the following code to unlock your admin account using database:

UPDATE admin_user SET `password` = md5('YOUR_NEW_PASSWORD'), is_active = 1 WHERE `username` = 'YOUR_ADMIN_USERNAME';

Or you can create a new admin account. Just add this code in admin.php file and put the file on your magento root folder. After this just access this file www.example.com/admin.php Your new

username: magento
password: magento1234

error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
ini_set('display_errors', 1);

Mage::app(Mage::app()->getStore()->getCode());//if you changed the code for the default store view change it here also
$username = 'magento';//desired username
$firstname = "Magento";//desired firstname
$lastname = "Developer";//desired lastname
$email = "[email protected]";//desired email
$pass = 'magento1234';//desired password
$user = Mage::getModel('admin/user')->load($username, 'username');
if ($user->getId()){
 echo "User {$username} already exists";


$result = $user->validate();
if (is_array($result)){
 foreach ($result as $res){
  echo $res."\n";

 echo "User {$username} was created";

catch (Exception $e){
 echo $e->getMessage();
  • Glad to hear this
    – Robert
    Commented Nov 2, 2017 at 7:54

If you are using N98-magerun , you should simply execute this command:

../n98-magerun.phar admin:user:unlock {admin_username}

very very simple

just go PhpMyAdmin

find admin_user

click edit

password section add your password and select md5 on right side

click GO button


if this helpful please thumpsUp. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.