Locked Out from Magento admin?

Locked Out from Magento admin?

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 😉

You made it all the way down here so you must have enjoyed this post! You may also like:

Moving Magento store to another server Marko Martinovic
Marko Martinovic, | 13

Moving Magento store to another server

Create Windows virtual hosts for your Magento projects Nikola Stojiljkovic
Nikola Stojiljkovic, | 8

Create Windows virtual hosts for your Magento projects

Solving problems with Category tree database information Nikola Stojiljkovic
Nikola Stojiljkovic, | 19

Solving problems with Category tree database information

75 comments

  1. This is what I got:

    Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[28000] [1045] Access denied for user ‘oralbmagento’@’97.74.215.236′ (using password: YES)’ in /home/content/d/e/n/dent8343/html/lib/Zend/Db/Adapter/Pdo/Abstract.php:129 Stack trace: #0 /home/content/d/e/n/dent8343/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct(‘mysql:host=oral…’, ‘oralbmagento’, ‘Passw0rd’, Array) #1 /home/content/d/e/n/dent8343/html/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect() #2 /home/content/d/e/n/dent8343/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(300): Zend_Db_Adapter_Pdo_Mysql->_connect() #3 /home/content/d/e/n/dent8343/html/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect() #4 /home/content/d/e/n/dent8343/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(‘SET NAMES utf8’, Array) #5 /home/content/d/e/n/dent8343/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query(‘SET NAMES utf8’, Array) #6 / in /home/content/d/e/n/dent8343/html/lib/Zend/Db/Adapter/Pdo/Abstract.php on line 144

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

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

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

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

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

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

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

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

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

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

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

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

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

  15. Just wondering.

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

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

    Help. .!

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

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

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

    That applies to any application.

  19. 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?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.