Discuz! 站點經常遇到的問題就是惡意註冊和惡意灌水網站在被灌水後整個網站整體體驗就會下降
註冊量大了之後會造成空間佔用龐大、查詢速度下降等問題
而後台刪除功能非常消耗系統性能
並且容易造成誤操作刪除管理員等問題
因此通過數據庫直接刪除會員以及相關信息會極大的提高刪除效率
在此提供一些常用的關聯刪除方法方便各位站長使用
執行 sql 可以通過 phpmyadmin 進行
如果沒有 phpmyadmin 的站長可以通過修改 config_global.php

  1. $_config['admincp']['runquery'] = '0';

其中 0 改成 1

  1. $_config['admincp']['runquery'] = '1';

這樣就可以通過後台-站長-數據庫-升級執行 sql 語句

一般註冊機與灌水機都是批量的註冊論壇模板賬户並灌水發帖
因此註冊的 uid 一般是連續的
可以通過 uid 來批量刪除用户及相關數據
比如大於某 uid 的批量刪除的 sql

  1. set @delid = 1000000;
  2. delete from pre_home_feed where uid > @delid;
  3. delete from pre_home_share where uid > @delid;
  4. delete from pre_home_comment where uid > @delid;
  5. delete from pre_home_blogfield where uid > @delid;
  6. delete from pre_home_blog where uid > @delid;
  7. delete from pre_home_class where uid > @delid;
  8. delete from pre_home_pic where uid > @delid;
  9. delete from pre_common_member where uid > @delid;
  10. delete from pre_common_member_count where uid > @delid;
  11. delete from pre_common_member_field_forum where uid > @delid;
  12. delete from pre_common_member_field_home where uid > @delid;
  13. delete from pre_home_album where uid > @delid;
  14. delete from pre_home_docomment where uid > @delid;
  15. delete from pre_home_doing where uid > @delid;
  16. delete from pre_home_notification where authorid > @delid;
  17. delete from pre_forum_post where authorid > @delid;
  18. delete from pre_forum_thread where authorid > @delid;
  19. delete from pre_portal_comment where uid > @delid;
  20. delete from pre_common_member_profile where uid > @delid;
  21. delete from pre_common_member_status where uid > @delid;
  22. delete from pre_ucenter_members where uid > @delid;

其中

  1. set @delid = 1000000;

是定義 uid=1000000
大於該 uid 的用户和關聯數據全部刪除
可以根據自己站點實際情況定義該值
其中的語句可以單獨拆分進行處理

刪除數據後還要對網站進行一下掃尾工作
1. 登錄後台-工具-更新緩存,避免前台數據與實際數據不吻合。
2. 登錄後台-站長-數據庫-優化,對數據庫碎片進行優化,減少佔用,提升效率。