22

after installing magento in my local machine I forgot admin password what I have given. I am not able to login to my admin area how can I reset the password

I have read this article http://www.atwix.com/magento/reset-admin-password-mysql/ but it is not working for me. Or may be I am not getting this

please help me am a beginner of Magento

4
  • Did you find the rigth value for the salt variable?
    – RST
    Jun 7, 2013 at 11:44
  • What you are not getting in this article?
    – Mufaddal
    Jun 7, 2013 at 11:45
  • 1
    I got the solution app/code/core/Mage/Core/Model/Session/Abstract/Varien.php we have to comment 89,90,91 lines Jun 7, 2013 at 12:52
  • didn't work @SujithWayanad
    – ahnbizcad
    Apr 27, 2015 at 10:59

15 Answers 15

31

Go To :

1 - Login in to PhpMyadmin .

2 - Jump in to Magento's database .

3 - Go to admin_user table and edit the table .

4 - put a "password" (which you want) and select MD5 from function dropdown (Important).

This is working both in CE And EE latest version (tested in both latest version), no need of core file changes.

4
  • I have tried that I think it is working after signing in I am not getting error message but the page is redirecting to the same login again instead of admin page
    – Yavana
    Jun 7, 2013 at 12:42
  • 4
    If you are working on a local machine with WAMP, comment out all lines that have to do with $cookieParams in app/code/core/Mage/Core/Model/Session/Abstract/Varien.php (For me thats lines 88 to 108 with Magento EE 1.13) Jun 7, 2013 at 20:46
  • 1
    This method no longer works in newer version of magentro Jul 7, 2015 at 10:07
  • @EmilStewart : Thanks, this is the real answer. Working fine with newer versios. Aug 6, 2015 at 6:27
21

This would prove to be a good resource to read: http://www.magentocommerce.com/wiki/recover/resetting-admin-password

SELECT * FROM admin_user;

Then, find the username you want to modify in the listing provided - ‘admin’ in this example. Then, to update the password, type:

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

‘qX’ would be changed to whatever you want it to be and same goes for ‘password’

2
  • 7
    just to clarify a bit more: qX will be the salt, and password will be the final password.
    – Enrique
    Dec 4, 2013 at 15:29
  • 1
    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.
    – carbide20
    Jan 25, 2015 at 4:47
10

Mostly, when we install the Magento Community on our local computer (XAMPP, WAMPP), it looks like we can't log in as the administrator from the backend. The system will prompt us we input the wrong password, but it's not the truth.

When i come up with this issue, i tried to reset the password by following method (in SQLyog).

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

‘password’ should be set to whatever you want for your new password, and ‘qX’ would be any random characters you like.

But we still can not log in. At first, I thought this method is wrong method. While, the 'admin' password definitely had been changed. But why we still can not log in?

Maybe we have input the right user name and password, but we still can't log in.

Use Notepad ++ to open and edit core file: app/code/core/Mage/Core/Model/Session/Abstract/Varien.php, within your magento directory and comment those below lines:

$cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath() //,
            // 'domain'   => $cookie->getConfigDomain(),
            // 'secure'   => $cookie->isSecure(),
            // 'httponly' => $cookie->getHttponly()
        );

And try again, you should can log in as admin from the backend.

The problem is Localhost or "127.0.0.1" are not true domains, and browsers allow only real domains to store cookies, that's why login stops and with invalid Username or Password.

5
  • 1
    awesome! thanks! i have changed and reinstalled magento several times only to find out this solution. Damn!
    – KD.
    Mar 20, 2015 at 9:45
  • Is this a bad thing to do for production? Do you need to toggle these comments back and forth between development and production? Is there a more sustainable way?
    – ahnbizcad
    Apr 27, 2015 at 10:17
  • Still not working for me. I just get "access denied". When It's an invalid name or password, it tells me that error message, so my credentials are correct when it says "access denied". Where is the additional permissions to be set?
    – ahnbizcad
    Apr 27, 2015 at 10:21
  • When I went through the initial magento setup, I believe I made an admin user, but now the admin_user table has zero entries. I added one in manually. It's still invalid. I made sure to use md5 hash function for the password field. Are there other fields necessary?
    – ahnbizcad
    Apr 27, 2015 at 10:25
  • I use MD5 without salt & change the Varien.php as you did then it works
    – Duc Tran
    Jul 11, 2015 at 5:31
7

The way I usually do it is as follows:

Add this snippet somewhere in your login.phtml template app/design/adminhtml/default/default/template/login.phtml

Mage::getSingleton('core/session', array('name' => 'adminhtml'));
$user = Mage::getModel('admin/user')->loadByUsername('YOUR_USERNAME');
$session = Mage::getSingleton('admin/session');
$session->setUser($user);

Replace 'YOUR_USERNAME' with your admin user name. Go to the login page (yourdomain.com/admin), now your admin session has been set. When you go to the login page again, you should be automatically logged in. Now you can reset your password in system > permissions > users.

Don't forget to remove the snippet from your template once your are logged in.

It might not be the best answer but it has always worked for me.

3
  • 1
    It is the best answer in terms of avoiding fiddling with the database directly.
    – Milind R
    Mar 5, 2015 at 22:14
  • @MilindR as if editing a hard-to-remember, obscurely located file, with having to know a DSL is better? Editing the database is far more intuitive, and requires less additional knowledge.
    – ahnbizcad
    Apr 27, 2015 at 9:47
  • @ahnbizcad "in terms of avoiding fiddling with the database directly"
    – Chris
    Apr 29, 2015 at 6:46
5

Poking around in the database is a horrible idea, when you've got an entire framework at your fingertips. This is the proper way of changing the admin password:

Create a file called reset-password.php and place it in the site root:

<?php

chdir(dirname(__FILE__));
require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);
umask(0);

$user = Mage::getModel('admin/user')
    ->load('admin', 'username')
    ->setNewPassword('mynewpassword')
    ->save();

Make a request for /reset-password.php in your browser, and the Magento framework should update the password for admin to mynewpassword.

5
  • I have no idea WHERE to put that code. The location should be specified from the root directory, nor a randomly assumed base directory that's not mentioned.
    – ahnbizcad
    Apr 27, 2015 at 10:06
  • and does it tell you if you need to manually run it or not? nope.
    – ahnbizcad
    Apr 27, 2015 at 10:08
  • As it says in the article, start off by making a copy of cron.php.
    – Saustrup
    Apr 28, 2015 at 11:39
  • 1
    Updated the answer to reflect filename, location and contents.
    – Saustrup
    Jun 2, 2015 at 14:15
  • This must be the easiest method and it works with the latest version. Thanks Man! Oct 22, 2015 at 9:53
4

This solution work for all versions of Magento.

Add temporally this at end of index.php

$user = Mage::getModel('admin/user')->loadByUsername('your_username');
$user->setPassword('new_password');
$user->save();

And your new_password was saved. Now remove 3 lines at the end of index.php.

Have a nice day.

1
  • Not working. password is changing. But login is not done Aug 19, 2015 at 9:37
2

If you have access to phpMyAdmin, here are the steps to reset your password.

First, open up phpMyAdmin. Click on your database name for Magento from the sidebar on the left. Click on the SQL tab and type the following in to the text box:

UPDATE `admin_user` SET `password` = MD5('PASSWORD') WHERE `username` = 'USERNAME';

You’ll want to replace the capitalized values with the correct information:

USERNAME - The user whose password you’ll be udpating PASSWORD - The new password you want to use For example, if my username was admin and I wanted to reset the password to 123456, I would do this:

UPDATE `admin_user` SET `password` = MD5('123456') WHERE `username` = 'admin';

If you don’t know the name of the user you want to update, you can see all the users by clicking on the admin_user link from the sidebar, and then select the Browse tab. The username column has the list of available users.

2

To reset your admin password, you have to create a file and paste the bellow code into this file and upload it in your magento root directory.

<?php
require_once 'app/Mage.php';
umask(0);
/* not Mage::run(); */
Mage::app('default');

## For magento1.7 or Earlier var
//$_HASH_SALT_LENGTH = 2;
## For magento1.8 and magento1.9
$_HASH_SALT_LENGTH = 32;

#Generate admin password
$password = "admin1234";
echo $adminPass = Mage::helper('core')->getHash($password, $_HASH_SALT_LENGTH);
## And reset password field in "admin_user" table

?>

And that’s it, now you are able to login from admin using by this given password.

For detail about reset admin password, Please go to my blog link http://www.scriptlodge.com/how-to-reset-admin-password-in-magento/

1

3 Steps without MySql

To login into magento admin, using only ftp access is a little tricky.

Step 1 :

open the class Mage_Admin_Model_User located at app\code\core\Mage\Admin\Model\User.php.

Step 2 :

Next find the authenticate() function around line no: 225. Inside the authenticate function, this code is written,

$this->loadByUsername($username);

You need to add the line return true; after this,

$this->loadByUsername($username);
return true;

Step 3 :

And that’s it, now you login in admin using any password. Since, we have skipped the code for password checking, login using any password and then change the password in admin from

System -> Permission -> Users.

4
  • there is no "app/" in my linux root directory.
    – ahnbizcad
    Apr 27, 2015 at 10:02
  • 1
    @ahnbizcad not in linux root directory. Look at your magento root directory
    – Vinod VT
    Apr 27, 2015 at 10:05
  • There is a lot of code after it. And the end of the function has a return. Idk if this is outdated.
    – ahnbizcad
    Apr 27, 2015 at 10:14
  • 1
    Just search for $this->loadByUsername($username); in User.php and put return true just below the line. :)
    – Vinod VT
    Apr 27, 2015 at 10:17
0

Open phpMyAdmin and under open your database and under that find table "admin_user" and find your username in that table. Delete the password over there and create a new MD5 hash of your new password and place it there.

0
<?php
$pass = "12345678";
  $salt = "EI";
  echo md5($salt.$pass).":".$salt;
?>
Update 'admin_user' table password field with the output of above program.

Follow below link for more information...
[http://www.atwix.com/magento/reset-admin-password-mysql][1]
0

$date = new DateTime();

$password = "b919ec4a25be3bc46c00895a0eb4f907:c20ad4d76fe97759aa27a0c99bff6710";

$sql = "UPDATE yourmagentoDB.admin_user SET password = \'".password."\', rp_token_created_at = ". $date->getTimestamp() ." WHERE admin_user.user_id = ".$user_id;

For example, your password is: frank123. Think of of any string of at least two bits. In my case i will take my new password to be “frank123” and salt to be “MD5(12)”. Next go to any md5 generator site and generate md5 of string “c20ad4d76fe97759aa27a0c99bff6710frank123”. The md5 in my case being “b919ec4a25be3bc46c00895a0eb4f907″. Now, edit the table row with the above script.

see how to use FTP below

http://excellencemagentoblog.com/how-to-reset-magento-admin-passwor

0

Follow the below procedure to reset Magento User Password:

1) Login to PhpMyAdmin.

2)Open Magento Database.

3)Now open "admin_user" table if you not set any table prefix at the time installing Magento, Or if you set table prefix then open "prefixadmin_user" Table.

4)Now in User password field you can see MD5 Hash converted password. So first you need to convert your plain text into MD5 Hash format and after that copy the MD5 Hast format password and paste it in User Password field under "prefixadmin_user" database table.

0

Get List of Users:

*Note: Add your table prefix before table name.

SELECT * FROM admin_user; Then, find the username you want to modify in the listing provided - ‘admin’ in this example. Then, to update the password, type:

UPDATE admin_user SET password=CONCAT(MD5('qXpassword'), ':qX') WHERE username='admin'; ‘qX’ would be changed to whatever you want it to be and same goes for ‘password’

You can also do this in phpMyAdmin, find the admin_user field and choose MD5 when updating password.

If you want to add a new admin user, you must not only create a new entry in the table ‘admin_user’, but you also have to insert an entry in the table ‘admin_role’ which has to be associated with the user by the field ‘user_id’.

0

The cleanest way to fix this issue is to reset the Magento installation; be sure you keep details of your database credentials in a safe place:

  1. Delete local.xml in app\etc
  2. Delete \var\cache content
  3. Delete \var\session content
  4. Run the installation script in the browser with http://yourdomain/index.php
  5. Run the first screen (Localization)
  6. In the second screen, enable "Skip Base URL Validation Before the Next Step"
  7. Clean browser cache and cookies

Works 100% of the times.

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.