47

Forgot Prestashop Admin Password (No Reminder Email Sent)


Article posted on Friday, 13th, July, 2012 at 12:58 pm


Sometimes in life, your browser needs reinstalling, and all those saved passwords get wiped. You’ve made the mistake of relying on your browser to store your Prestashop admin password and now you’ve forgotten it.

After clicking on ‘forgot password’, you infuriatingly do not get sent an email saving you from losing access to your site, and you don’t know how to go get it back.

If this sounds familiar, read on… 

Quite simply, you’re going to have to dabble with some MySQL on your server. If you don’t have access to your own installed databases (Prestashop requires a MySQL database to run), then you’re going to have to ask your web admin folk!

Assuming you can access your own databases, you need to use something like PhpMyAdmin / TOAD to browse your tables. If you’re feeling brave, try the command line option!

First off, you need to access a file called settings.inc.php. This is on your web server under your shop directory in a folder called ‘config’. Download and open this file.

In the php file, you’ll see a list of parameters Prestashop uses to connect you to your DB. Make a note of the DB settings and use them to connect to your DB using PhpMyAdmin / whatever.

define('_MYSQL_ENGINE_', 'InnoDB');
define('_DB_SERVER_', 'db.webhost.com');
define('_DB_USER_', 'username');
define('_DB_PREFIX_', 'pr_');
define('_DB_PASSWD_', 'password');

Once you’re able to browse your DB, you need to go to the employee table. Note the DB_PREFIX option in settings.inc.php (in this case ‘pr_’) and go to the employee table with that prefix, in my case, pr_employee.

When in there, we need to run an SQL query updating the password field. The stored password is encrypted using an MD5 hash, but if you’ve already tried simply adding a new hash to the DB, you will have found that this doesn’t work!

The reason for this is that the Prestashop system uses a cookie key to add an extra bit of complexity to your MD5 hash. this key is also found in your config.inc.php file:

define('_COOKIE_KEY_', '6zQtryWZo123The8i2WLWjSxrDtlO0... [etc]');

Keep this to hand, as you’ll need it for your SQL query.

In the employee section of your DB browser, seek out the bit where you can run SQL queries of your own and paste the following code into it:

UPDATE pr_employee
SET passwd=md5('6zQtr ... T4z7new_password')
WHERE id_employee = 1;

Points to remember:

  • Make sure you adjust your employee table so that it has the correct DB_PREFIX as mentioned above,
  • Paste the full cookie key, immediately followed by the new password (no spaces)
  • Obviously make sure the employee id is the one you want to change!

Once done, run the query and providing the query ran successfully, you’re good to go!

Log in with your new password via the prestashop admin and rejoice at the sight of your much-more-appreciated back office!

 



Tags: , , , , , , ,

Join in the Conversation


comments powered by Disqus