bulk deleting users from moodle using mysql
Login to mysql, e.g.
mysql -u root -p[password_for_database]
type:
use database mymoodle; [where mymoodle is the name of your moodle database]
Suppose now that you want to delete ALL users except "john" and "admin", you would type:
delete from mymoodle.mdl_users where (username not like "%admin%" and username not like "%john%");
exit;
That's all.