Difference between revisions of "Administration - I accidentally lost my admin account! What can I do" From Online Manual

Jump to: navigation, search
(Separate other approaches from administrate.php approach)
Line 12: Line 12:
 
* Upload the file, administrate.php, to your forum directory (where SSI.php is found)
 
* Upload the file, administrate.php, to your forum directory (where SSI.php is found)
 
* Using your browser, visit administrate.php
 
* Using your browser, visit administrate.php
 
+
==Other approaches==
==Setting a new user account up to be admin==
+
===Setting a new user account up to be admin===
 
The below queries will add you back as an administrator on an SMF forum. ''' Don't forget to replace smf_ with your database prefix.'''  These queries can be run from within [[phpMyAdmin]], or, if you do not have phpMyAdmin installed, from a simple single-purpose script.
 
The below queries will add you back as an administrator on an SMF forum. ''' Don't forget to replace smf_ with your database prefix.'''  These queries can be run from within [[phpMyAdmin]], or, if you do not have phpMyAdmin installed, from a simple single-purpose script.
===SMF 1.1===
+
====SMF 1.1====
 
Run this query:
 
Run this query:
 
{{code|1=UPDATE smf_members SET ID_GROUP = '1' WHERE memberName = 'adminsusername'}}
 
{{code|1=UPDATE smf_members SET ID_GROUP = '1' WHERE memberName = 'adminsusername'}}
  
===SMF 2.0===
+
====SMF 2.0====
 
Run this query:
 
Run this query:
 
{{code|1=UPDATE smf_members SET id_group = '1' WHERE member_name = 'adminsusername'}}
 
{{code|1=UPDATE smf_members SET id_group = '1' WHERE member_name = 'adminsusername'}}
Line 25: Line 25:
 
In addition, SMF 2.0 allows you to re-attribute posts through the [[Forum Maintenance]] section of your [[Administration Center]] (Administration Center > [[Forum Maintenance]] > ''Reattribute User Posts''). You just need to fill in the form using the e-mail address or username of the old user account, and the username for the user who is to have those posts. This only works for guest posts (remaining posts from deleted members are considered guest posts).
 
In addition, SMF 2.0 allows you to re-attribute posts through the [[Forum Maintenance]] section of your [[Administration Center]] (Administration Center > [[Forum Maintenance]] > ''Reattribute User Posts''). You just need to fill in the form using the e-mail address or username of the old user account, and the username for the user who is to have those posts. This only works for guest posts (remaining posts from deleted members are considered guest posts).
  
===Creating a single-purpose script===
+
====Creating a single-purpose script====
 
*Create a php file called '''createadmin.php'''
 
*Create a php file called '''createadmin.php'''
 
*Copy and paste in it the code below according to your SMF version
 
*Copy and paste in it the code below according to your SMF version
Line 33: Line 33:
 
*Afterwards, make sure to delete the file from your forum's directory.
 
*Afterwards, make sure to delete the file from your forum's directory.
  
====SMF 1.1====
+
=====SMF 1.1=====
 
{{code|1=<nowiki><?php
 
{{code|1=<nowiki><?php
  
Line 54: Line 54:
 
?></nowiki>}}
 
?></nowiki>}}
  
====SMF 2.0====
+
=====SMF 2.0=====
 
{{code|1=<nowiki><?php
 
{{code|1=<nowiki><?php
  
Line 78: Line 78:
 
?></nowiki>}}
 
?></nowiki>}}
  
==But I need admin to activate the new account before I can log in==
+
===But I need admin to activate the new account before I can log in===
 
Solution: turn off account activation altogether.
 
Solution: turn off account activation altogether.
 
In phpMyAdmin, or in a single-purpose script, run the appropriate query for your version of SMF.
 
In phpMyAdmin, or in a single-purpose script, run the appropriate query for your version of SMF.
 
Afterwards, be sure to set account activation back the way you want it.
 
Afterwards, be sure to set account activation back the way you want it.
===SMF 1.1===
+
====SMF 1.1====
 
{{code|1=UPDATE smf_members SET is_activated = 1 WHERE memberName = 'yourusername';}}
 
{{code|1=UPDATE smf_members SET is_activated = 1 WHERE memberName = 'yourusername';}}
===SMF 2.0===
+
====SMF 2.0====
  
 
The smf SSI php script above will automatically activate the account, but if you prefer to use phpmyadmin direct then the following query will activate the user....
 
The smf SSI php script above will automatically activate the account, but if you prefer to use phpmyadmin direct then the following query will activate the user....
Line 90: Line 90:
 
{{code|1=UPDATE smf_members SET is_activated = 1 WHERE member_name = 'yourusername';}}
 
{{code|1=UPDATE smf_members SET is_activated = 1 WHERE member_name = 'yourusername';}}
  
==But I forgot my password and I cannot create a new account==
+
===But I forgot my password and I cannot create a new account===
 
In phpMyAdmin, or in a single-purpose script, run this query:
 
In phpMyAdmin, or in a single-purpose script, run this query:
 
{{code|1=UPDATE {$db_prefix}_settings SET value = 0 WHERE variable = 'registration_method';}}
 
{{code|1=UPDATE {$db_prefix}_settings SET value = 0 WHERE variable = 'registration_method';}}
 
Afterwards, be sure to set the registration method the way you want it.
 
Afterwards, be sure to set the registration method the way you want it.
  
==I need to create a new account for admin, but my forum is in maintenance mode==
+
===I need to create a new account for admin, but my forum is in maintenance mode===
 
{{For more information|about=setting the value of $maintenance in your Settings.php file|Settings.php#.24maintenance{{!}}$maintenance}}
 
{{For more information|about=setting the value of $maintenance in your Settings.php file|Settings.php#.24maintenance{{!}}$maintenance}}
  
==Reseting an admin users password==
+
===Reseting an admin users password===
 
Locate the user you wish to reset their password in the members table in phpmyadmin or similar. In the passwd field put in your new plain text password, in the password_salt field delete everything in the field. When you log in with the account with the new password you set, smf will automatically encrypt the password for future use.
 
Locate the user you wish to reset their password in the members table in phpmyadmin or similar. In the passwd field put in your new plain text password, in the password_salt field delete everything in the field. When you log in with the account with the new password you set, smf will automatically encrypt the password for future use.
  
 
[[Category:FAQ]]
 
[[Category:FAQ]]

Revision as of 09:06, 2 October 2012

If you accidentally delete your administrator account, you will need to register again and run the appropriate query for your SMF version.

If you lose your administrator membergroup and privileges due to a mistake or conversion, you will need to run the appropriate query for your SMF version, but you do not have to register your account again.

Script for SMF 2.0 -- administrate.php

Interested parties have created the administrate.php script for SMF 2.0 to solve this problem. This script is not officially supported. Please use at your own descretion. Please back up your database before you being.

To begin,

  • log in to the forum.
  • Upload the file, administrate.php, to your forum directory (where SSI.php is found)
  • Using your browser, visit administrate.php

Other approaches

Setting a new user account up to be admin

The below queries will add you back as an administrator on an SMF forum. Don't forget to replace smf_ with your database prefix. These queries can be run from within phpMyAdmin, or, if you do not have phpMyAdmin installed, from a simple single-purpose script.

SMF 1.1

Run this query:

UPDATE smf_members SET ID_GROUP = '1' WHERE memberName = 'adminsusername'

SMF 2.0

Run this query:

UPDATE smf_members SET id_group = '1' WHERE member_name = 'adminsusername'

In addition, SMF 2.0 allows you to re-attribute posts through the Forum Maintenance section of your Administration Center (Administration Center > Forum Maintenance > Reattribute User Posts). You just need to fill in the form using the e-mail address or username of the old user account, and the username for the user who is to have those posts. This only works for guest posts (remaining posts from deleted members are considered guest posts).

Creating a single-purpose script

  • Create a php file called createadmin.php
  • Copy and paste in it the code below according to your SMF version
  • Replace in the code adminusername with the login name you want to set as admin.
  • Using FTP upload it to your forum directory -- the same directory that has SSI.php in it.
  • Run the script, accessing it from your browser by URL as
    http://www.yourwebsite.tld/forum/createadmin.php.
  • Afterwards, make sure to delete the file from your forum's directory.
SMF 1.1
<?php

// Pick a username to be the new admin user -- use the login name, not the display name
$yourusername='adminusername';

//---------------------------------------------------------------------------

// You shouldn't need to change anything past this point in the script.
//Here we include SSI for globals used within the sql statement
include_once('SSI.php');
global $db_prefix;

//  Now run the query.
$querystring='UPDATE ' . $db_prefix . 'members
SET ID_GROUP = \'1\' WHERE memberName = \'' . $yourusername . '\'';
$adminsquirt = db_query($querystring, __FILE__,  __LINE__);

echo $yourusername . ' should now be an admin';
?>
SMF 2.0
<?php

// Pick a username to be the new admin user -- use the login name, not the display name
$yourusername='adminusername';

//---------------------------------------------------------------------------

// You shouldn't need to change anything past this point in the script.
//Here we include SSI for globals used within the sql statement
include_once('SSI.php');

//  Now run the query to elevate the user to administrator
$querystring='UPDATE {db_prefix}members
SET id_group = \'1\' WHERE member_name = \'' . $yourusername . '\'';
$adminElevate = $smcFunc['db_query']('', $querystring, array());

//Make sure that the account is activated!
$querystringb='UPDATE {db_prefix}members SET is_activated = 1 WHERE member_name = \'' . $yourusername . '\'';
$adminActivate = $smcFunc['db_query']('', $querystringb, array());

echo $yourusername . ' should now be an admin';
?>

But I need admin to activate the new account before I can log in

Solution: turn off account activation altogether. In phpMyAdmin, or in a single-purpose script, run the appropriate query for your version of SMF. Afterwards, be sure to set account activation back the way you want it.

SMF 1.1

UPDATE smf_members SET is_activated = 1 WHERE memberName = 'yourusername';

SMF 2.0

The smf SSI php script above will automatically activate the account, but if you prefer to use phpmyadmin direct then the following query will activate the user....

UPDATE smf_members SET is_activated = 1 WHERE member_name = 'yourusername';

But I forgot my password and I cannot create a new account

In phpMyAdmin, or in a single-purpose script, run this query:

UPDATE {$db_prefix}_settings SET value = 0 WHERE variable = 'registration_method';

Afterwards, be sure to set the registration method the way you want it.

I need to create a new account for admin, but my forum is in maintenance mode

For more information about setting the value of $maintenance in your Settings.php file, see $maintenance

Reseting an admin users password

Locate the user you wish to reset their password in the members table in phpmyadmin or similar. In the passwd field put in your new plain text password, in the password_salt field delete everything in the field. When you log in with the account with the new password you set, smf will automatically encrypt the password for future use.