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

Jump to: navigation, search
(→‎SMF 2.0: use code template)
(added a suggestion for doing this without using phpMyAdmin)
Line 4: Line 4:
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.
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.


The below queries will add you back as an administrator on an SMF forum. ''' Don't forget to replace smf_ with your database prefix.'''  
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 in [[phpMyAdmin]]:
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 in [[phpMyAdmin]]:
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'}}


Alternatively, 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===
Create a php file called '''createadmin.php''' copy it up to your forum directory -- the same directory with SSI.php. To run it, access it from your browser by URL as '''createadmin.php'''. Afterwards, make sure to delete the file from your forum's directory.
{{code|1=<?php
// Pick a username to be the new admin user -- use the login name, not the display name
$yourusername='adminusername';
// For smf 1.1, use these two (remove the two smf 2.0 lines)
$groupid_field = 'ID_GROUP';
$membername_field = 'memberName';
//for smf 2.0, use these two
$group_id='id_group';
$membername_field = 'member_name';
//---------------------------------------------------------------------------
// 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 ' . $groupid_field . ' = \'1\' WHERE ' . $membername_field . ' = \'' . $yourusername . '\'';
$adminsquirt = db_query($querystring, __FILE__,  __LINE__);
?>}}
[[Category:FAQ]]
[[Category:FAQ]]

Revision as of 13:52, 7 September 2011

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.

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 it up to your forum directory -- the same directory with SSI.php. To run it, access it from your browser by URL as createadmin.php. Afterwards, make sure to delete the file from your forum's directory.

<?php

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


// For smf 1.1, use these two (remove the two smf 2.0 lines)
$groupid_field = 'ID_GROUP';
$membername_field = 'memberName';

//for smf 2.0, use these two
$group_id='id_group';
$membername_field = 'member_name';

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

// 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 ' . $groupid_field . ' = \'1\' WHERE ' . $membername_field . ' = \ . $yourusername . '\;
$adminsquirt = db_query($querystring, __FILE__,  __LINE__);

?>


Advertisement: