0

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 1.9.3.3

4 Answers 4

1

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.

7

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

<?php
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);

Mage::app(Mage::app()->getStore()->getCode());//if you changed the code for the default store view change it here also
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$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";
 exit;
}

$user->setUsername($username)
  ->setFirstname($firstname)
  ->setLastname($lastname)
  ->setEmail($email)
  ->setPassword($pass)
  ;

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

try{
 $user->setForceNewPassword(true);
 $user->save();
 $user->setRoleIds(array(1))->saveRelations();
 echo "User {$username} was created";
 exit;
}

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

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

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

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

DONE!

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.