Locked Out from Magento admin?
25 Comments 12th DEC 2009 | Posted by Ivan Weiler in Magento

Here’s the situation, you, client, webmaster, pet or whoever was playing with users and roles in your favorite store and deleted only main admin account or broke admin account privileges. If it happened to you and you’re locked out from your Magento store, read on.
This script creates new admin user associated to new Inchoo role with all privileges set. Of course, you have to have FTP access for this to work.
Download newadmin script, unpack it, open newadmin.php file (notepad will do) and define username, email and password of the new user. Username and email must be UNIQUE in Magento, so use some new ones and not the old ones that are already in the system, you’ll change it later after you login.
Connect with FTP and copy newadmin.php file to root of your store and run it through web browser like
http://www.yourstore.com/newadmin.php
The script will try to delete itself after user is created, but please make sure it’s removed from the server. Code is tested on 1.3.x versions of Magento and I don’t believe it will work on older versions, so please write some feedback.
Regards
To post code in comments, place your code inside [code] and [/code] tags.


















December 12th, 2009 at 16:36
OK, theoretically, is that right that if someone has write access to one of magento’s directories on the server with the help of this script he can get an access to magento admin and all the confidential data?
December 12th, 2009 at 19:33
WOW thanks dude fix it!
December 13th, 2009 at 1:50
Yep, if you have read/write access to filesystem, you can do anything you want with the database.
That applies to any application.
December 14th, 2009 at 9:00
Just to make a simple note…
if you guys just need to change the password, that for some reason you don’t remember and email system is not working properly in order to retrieve the new password, just point your browser into this nice article:
http://www.magentocommerce.com/wiki/general/resetting-admin-password
December 22nd, 2009 at 20:12
Amazing. Worked like a charm, thanks!
December 31st, 2009 at 17:21
When I downloaded the ZIP file, WINZIP says it is not a valid zip file. Could it have gotten corrupted? Is it WINZIP compatible?
December 31st, 2009 at 17:59
Hey David,
Go to celebrate new year. It is no time to write about Magento.
January 29th, 2010 at 15:24
WOW thanks!!!!!!
February 17th, 2010 at 18:45
Is there an extension that can check a magento install and make sure all the files and folder have proper read-write permissions? I had to play around with permissions a lot when installing extensions, I feel like I might have opened the pandora box.
March 19th, 2010 at 19:01
Just wondering.
Root is the public_html/teejmart.com .. right?
Not sure which username, email and password to define though.
Help. .!
March 20th, 2010 at 10:19
@Alvin: root folder is the one on your server where app, js, lib, media, skin, cron.php and other Magento folders and files are placed. It’s probably somewhere in public_html yes.
This script creates new admin user, so use any username, email and password you would like him to have.
March 20th, 2010 at 16:55
Thanks Ivan. So the location is correct.
When I open the file, I see
//define USERNAME, EMAIL and PASSWORD and uncomment(#) this 3 lines ..etc..
what do i have to do ..? how do I “uncomment”? anyway, I changed all the username, email, and password to the ones I want.
When on the browser I got http://www.teejmart.com/newadmin.php – all i got is this
Edit this file and define USERNAME, EMAIL and PASSWORD.
I must have missed some details.
Alvin
March 20th, 2010 at 18:09
@Alvin: Just remove # from beginning of those 3 lines and save the file.
March 20th, 2010 at 19:42
Ivan … thanks.
The solution seem so simple but for a non-programmer noob like me, it would take me hours and still not find the solution.
Thanks!!
April 12th, 2010 at 4:32
Hi there. I tried this process by uncommenting the three lines, uploading the file, callling it from a browser and after entering the login and password of inchoo/inchoo555 I’m given an ‘Access Denied’ error message.
I’ve tried other unique login/email/password names and get the same result every time.
Your help would be greatly appreciated.
Thanks.
April 12th, 2010 at 4:33
p.s. I’m on 1.3 on my own server.
May 18th, 2010 at 17:41
thank you very much. excellent!
May 25th, 2010 at 17:27
THANKS dude, you are the best.
May 27th, 2010 at 18:02
you’re awesome.
THANKS.
June 28th, 2010 at 14:08
Hi,
Ive been looking for hours for something like this as i have done the stupid and locked myself out!
But when i run it i get the following error:
Parse error: syntax error, unexpected ‘@’, expecting ‘)’ in /home/wiretekc/public_html/newadmin.php on line 34
August 5th, 2010 at 16:14
I confirm that the script works with 1.4. Good work guys!
August 5th, 2010 at 21:09
@Michal: Good to know, thanks for the feedback
August 8th, 2010 at 19:53
I found an easy solution at http://www.redstage.com/magento/blog/2010/03/11/magento-how-to-reset-the-admin-password/comment-page-1/?rcommentid=1782&rerror=incorrect-captcha-sol&rchash=6f992ca439d837af97d86bed798a2700#commentform
August 26th, 2010 at 10:41
works great, just what I needed. Thank you!
August 30th, 2010 at 20:01
I swear to god this site has helped me so much through the year with magento. You guys are great!!! I love this site alot and will always keep it as a bookmark. Thanx guys, this worked as always : )