SSbits - Home page
Site by Carbon Crayon
Submit a Post >

Snippets - Little bits of code to make you happy

How to access your admin account when you've forgotten the password

I managed to forget my admin password and found quite a few ways to unlock an SS install. I originally thought about poking around the database and changing the hashes myself. After reviewing the Security and password encryption code, I would recommend against doing that. SilverStripe uses salted SHA1 encryption which is no fun to try and create yourself. Also you'd have to update multiple tables to get the password changed. Luckily the SS Core team has included multiple features for accomplishing this. The options below assume you have access to your webserver to use some PHP code.

Option 1 - Set a Default Admin Login


Add the following to your _config.php:

Security::setDefaultAdmin('adminuser', 'password');

Option 2 - Use an Environment Configuration file

At the top level of your site folder create the file _ss_environment.php with the following code:

define('SS_DEFAULT_ADMIN_USERNAME', 'adminuser');
define('SS_DEFAULT_ADMIN_PASSWORD', 'password');

Option 3 - Use a Member DataObject

In some page controller, config, or any interpreted php file:

$m = DataObject::get_one('Member', "Email = ''");

Note: You could also grab MemberID 1 if you also forgot your email address.  Member ID 1 should be the admin in most cases.

That's it!

You should be able to get back in your admin account using any of the above examples.  Now be a little more careful with those passwords, eh?

  • Darren-Lee
    09/04/2011 1:19pm (6 years ago)

    Such an important tip - when I first started using Silverstripe, late 2009, this post came in very handy indeed!

  • Richard
    06/02/2013 10:58pm (4 years ago)

    Still works, thank you and thank God because I was really stuck.

Post a comment ...

You cannot post comments until you have logged in. Login Here.


Site of the Month

Find SSbits on

Top Contributers

Rank Avatar Name
1 article image Aram Balakjian
2 article image wfacewomens
3 article image Daniel Hensby
4 article image Marcus Dalgren
5 article image ryduhartchas
6 article image Hamish Campbell
7 article image Ty Barho
8 article image Martijn van Nieuwenhoven
9 article image Darren-Lee
10 article image Roman Schmid

View full leaderboard