blakcaps
blakcaps

Reputation: 2647

Programmatically Change Admin Password in Magento

I trying to change Magento admin password by,

Mage::getModel('admin/user')->loadByUsername('admin')->setPassword($password);

But this doesn't seem to be work.Any suggestions?

Upvotes: 3

Views: 4401

Answers (2)

Gershon Herczeg
Gershon Herczeg

Reputation: 3064

If you want to do it via a Query here is the query to run:

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

the resulting password would be 'password', qX is the salt you could use any 2 letter combo..

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

would make the password 123456 ...

Upvotes: 4

Seth Malaki
Seth Malaki

Reputation: 4486

You forgot to add save().

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

Upvotes: 7

Related Questions