註冊量大了之後會造成空間佔用龐大、查詢速度下降等問題
而後台刪除功能非常消耗系統性能
並且容易造成誤操作刪除管理員等問題
因此通過數據庫直接刪除會員以及相關信息會極大的提高刪除效率
在此提供一些常用的關聯刪除方法方便各位站長使用
執行 sql 可以通過 phpmyadmin 進行
如果沒有 phpmyadmin 的站長可以通過修改 config_global.php
- $_config['admincp']['runquery'] = '0';
其中 0 改成 1
- $_config['admincp']['runquery'] = '1';
這樣就可以通過後台-站長-數據庫-升級執行 sql 語句

一般註冊機與灌水機都是批量的註冊論壇模板賬户並灌水發帖
因此註冊的 uid 一般是連續的
可以通過 uid 來批量刪除用户及相關數據
比如大於某 uid 的批量刪除的 sql
- set @delid = 1000000;
- delete from pre_home_feed where uid > @delid;
- delete from pre_home_share where uid > @delid;
- delete from pre_home_comment where uid > @delid;
- delete from pre_home_blogfield where uid > @delid;
- delete from pre_home_blog where uid > @delid;
- delete from pre_home_class where uid > @delid;
- delete from pre_home_pic where uid > @delid;
- delete from pre_common_member where uid > @delid;
- delete from pre_common_member_count where uid > @delid;
- delete from pre_common_member_field_forum where uid > @delid;
- delete from pre_common_member_field_home where uid > @delid;
- delete from pre_home_album where uid > @delid;
- delete from pre_home_docomment where uid > @delid;
- delete from pre_home_doing where uid > @delid;
- delete from pre_home_notification where authorid > @delid;
- delete from pre_forum_post where authorid > @delid;
- delete from pre_forum_thread where authorid > @delid;
- delete from pre_portal_comment where uid > @delid;
- delete from pre_common_member_profile where uid > @delid;
- delete from pre_common_member_status where uid > @delid;
- delete from pre_ucenter_members where uid > @delid;
其中
- set @delid = 1000000;
是定義 uid=1000000
大於該 uid 的用户和關聯數據全部刪除
可以根據自己站點實際情況定義該值
其中的語句可以單獨拆分進行處理
刪除數據後還要對網站進行一下掃尾工作
1. 登錄後台-工具-更新緩存,避免前台數據與實際數據不吻合。
2. 登錄後台-站長-數據庫-優化,對數據庫碎片進行優化,減少佔用,提升效率。