Locked Out from Magento admin?

Featured Image

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.

newadmin.zip

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 ;)

45
Top

Enjoyed this post?

Subscribe to our RSS Feed, Follow us on Twitter and spread it to your friends!

Author

Ivan Weiler

Team Leader

Ivan is a team leader and a senior web developer. He gained lots of experience managing some of the most complex Magento projects we had at Inchoo.

Other posts from this author

Discussion 45 Comments

Add Comment
  1. 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?

  2. Chris

    WOW thanks dude fix it!

  3. Yep, if you have read/write access to filesystem, you can do anything you want with the database.

    That applies to any application.

  4. 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

    :)

  5. Michael De La Guera

    Amazing. Worked like a charm, thanks!

  6. David White

    When I downloaded the ZIP file, WINZIP says it is not a valid zip file. Could it have gotten corrupted? Is it WINZIP compatible?

  7. Hey David,

    Go to celebrate new year. It is no time to write about Magento.

  8. Alex Fort

    WOW thanks!!!!!!

  9. magento noob

    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.

  10. Just wondering.

    Root is the public_html/teejmart.com .. right?

    Not sure which username, email and password to define though.

    Help. .!

  11. @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.

  12. 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

  13. @Alvin: Just remove # from beginning of those 3 lines and save the file.

  14. 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!!

  15. JH

    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.

  16. JH

    p.s. I’m on 1.3 on my own server.

  17. Joseph Kelly

    thank you very much. excellent!

  18. THANKS dude, you are the best.

  19. Clara

    you’re awesome.
    THANKS.

  20. Chris

    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

  21. I confirm that the script works with 1.4. Good work guys!

  22. @Michal: Good to know, thanks for the feedback

  23. Sylvia

    works great, just what I needed. Thank you!

  24. Jim

    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 : )

  25. Robbie

    Brilliant. Helped me out thanks.

  26. AWESOME! I used it on a “Magento CE Version 1.4.1.1″ site and it worked great.

  27. great works –> you’re better than magento guys

  28. What could be easier than this!!
    Worked great… unlike many things in Magento.
    Thanks again!

  29. Jozsef

    Ivan,
    Please send us a step by step (or print screen) explanation how to do it.
    As Alvin says …for a non programmer it’s realy hard to understand.
    So. please HELP

  30. john

    pls help, there isnt any php file inside the compressed file… i only get a “newadmin” file without extension, when open it in notepad i only get strange symbols…

  31. john

    I had to use opera to download the zip file. Internet Explorer would not open it as it said corrupted file. Worked great!

  32. goma

    You saved my life, tnx

  33. hank

    Please help. I cannot login to my admin panel. This occured after i went into Magento configurations and limited the admin role.

    Now whenever I try to login, i get a message that says:

    Parent Role id ‘G8′ does not exist (along with a bunch of code)

    I tried logging in from a 2nd login that has “All” for Role and still no luck.

    I tried several fixes that you listed including newadmin.php and still no luck.

    The only message I get when I try newadmin.php is:

    Email, User Name already exists

    Any ideas would be much appreciated.

    Thank you,

    Hank

  34. Tobias Hoffmann

    Excellent work Ivan, thanks!

  35. Thank you so very much!

  36. Thank you THANK YOU!!! I have been locked out of my account all day and the script worked on version 1.5.0.1!!! I love you man!!

  37. I’m glad to hear that old tricks still work :)

  38. Rakesh

    Thanks it’s work fine :)

  39. GREAT WORKT!!!

    very useful script

    so it works on Magento ver. 1.5.1.0

  40. MC

    Thank you very much. We’ve spent all day trying the other “fixes” and nothing worked… even other “create new admin user” fixes.

    Your script worked great! We’re back up and running. I wish we’d found it first and not after 12 hours of searching.

  41. Great job..saved me a lot of time.. it alsoworks on Magento ver. 1.6.0.0

  42. ItCat

    Lifesaver !!! works great @ 1.5.1.0

  43. Karthick

    Susana it is used well. But im getting problem when looking to connect with the Magento connect…. im not only saying to susana but to all…. can you help me

  44. Thank you! This script is a life saver! Works for me on Magento Community 1.6 and Magento Pro 1.11.

Add Your Comment

Please wrap all source codes with [code][/code] tags.
Top