My wiki collected a lot of spam over the past few months, so I've blocked it to only registered users. Unfortunately I never turned off user registration. Is it possible to block a lot of user accounts at once, or should I just restart?
2 Answers
The quickest and least invasive way to prevent a big list of registered users from making modifications is probably to do a bulk password change for the unwelcome users.
Assuming you're running a Unix-like, and that the list of folks you want to keep is relatively low:
Disable anonymous viewing and/or editing. (which it sounds like you've already done?)
Dump a list of users from the database to a file.
eg., for MySQL:
mysql -p -u root -B wikidb -e 'select user_name from user;' | tee user.list
Remove the users you want to keep from the user.list file.
Use the MediaWiki password command-line tool to change passwords to something random.
eg.
cd [wiki-docroot]/maintenance/
while read wikiuser; do
echo $wikiuser;
php ./changePassword.php $wikiuser BOGUS%PASSblahblah77;
done <user.list
Generating a different password for each user is left as an exercise for the reader. :-)

- 1,362
- 8
- 16
-
Interesting way to do it. It's very cool to see how flexible shell scripts can be. EDIT: found it, a list of command line tools is here: http://www.mediawiki.org/wiki/Manual:Maintenance_scripts – Chris Jan 04 '12 at 21:32
-
1Yep, a nice list of command-line tools there. Too bad there isn't a bulk password changer among them. – Royce Williams Jan 05 '12 at 03:01
Connect to your mysql server:
mysql -h DBSERVER_HOST -u wikiuser wikidb -p
Enter your password at the prompt. Once in mysql prompt, search for the user
mysql> select user_id,user_name from user; +---------+------------+ | user_id | user_name | +---------+------------+ | 9 | spammer | | 7 | r2d2 | | 1 | admin | +---------+------------+
Delete every "user_id" you need with:
mysql> delete from user where user_id in(7,9);

- 291
- 1
- 3