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. 登入後臺-站長-資料庫-最佳化,對資料庫碎片進行最佳化,減少佔用,提升效率。