TA的每日心情 | 奋斗 8 分钟前 |
---|
签到天数: 3413 天 连续签到: 15 天 [LV.Master]2000FPS
|
发表于 2021-5-10 10:50:00
|
显示全部楼层
|阅读模式
来自:广东省东莞市 电信
注册登陆后可查看附件和大图,以及购买相关内容
您需要 登录 才可以下载或查看,没有账号?注册会员
x
Discuz论坛修改会员UID的方法
因为以前一个历史问题,论坛的UID,直接从两万多变成了16777215(也就是mediumint(8)的最大值,8位宽度的整形,也就是2^24),之后再注册,就无法注册了,提示UID已经存在,因为UID一直是最大的值,不能再往上增加了。当时的解决办法,只是为了应急,删除了一些表中的异常数据,但是在其它一些表中,仍然保留了很多和删除UID相关的数据。这次一并处理了。
和UID相关的表,本论坛的Discuz中大概有170张表(与插件也有关系,当然,这里演示的,如果一个表中有多个和UID相关的键,则当作两个表来处理,例如说朋友关系的表,就是两个UID的,一个是自己的UID,另一个是朋友的UID)。
涉及到的表
这里涉及到的表数量比较多,当然,有些表里面根本没有数据,也就没有必要去修改,这个得看自己的论坛数据库的具体内容。本论坛涉及到的表与键:
pre_common_admincp_member;uid
pre_common_admincp_session;uid
pre_common_block_favorite;uid
pre_common_block_item_data;uid
pre_common_block_permission;uid
pre_common_card_log;uid
pre_common_credit_log;uid
pre_common_credit_rule_log;uid
pre_common_credit_rule_log_field;uid
pre_common_diy_data;uid
pre_common_grouppm;authorid
pre_common_invite;uid
pre_common_invite;fuid
pre_common_magiclog;uid
pre_common_member;uid
pre_common_member_action_log;uid
pre_common_member_archive;uid
pre_common_member_connect;uid
pre_common_member_count;uid
pre_common_member_count_archive;uid
pre_common_member_crime;uid
pre_common_member_crime;operatorid
pre_common_member_field_forum;uid
pre_common_member_field_forum_archive;uid
pre_common_member_field_home;uid
pre_common_member_field_home_archive;uid
pre_common_member_grouppm;uid
pre_common_member_log;uid
pre_common_member_magic;uid
pre_common_member_medal;uid
pre_common_member_newprompt;uid
pre_common_member_profile;uid
pre_common_member_profile_archive;uid
pre_common_member_security;uid
pre_common_member_secwhite;uid
pre_common_member_status;uid
pre_common_member_status_archive;uid
pre_common_member_validate;uid
pre_common_member_verify;uid
pre_common_member_verify_info;uid
pre_common_mytask;uid
pre_common_onlinetime;uid
pre_common_report;uid
pre_common_searchindex;uid
pre_common_session;uid
pre_common_statuser;uid
pre_common_template_permission;uid
pre_common_uin_black;uid
pre_connect_disktask;uid
pre_connect_feedlog;uid
pre_connect_memberbindlog;uid
pre_connect_postfeedlog;uid
pre_dsu_paulsign;uid
pre_forum_access;uid
pre_forum_activity;uid
pre_forum_activityapply;uid
pre_forum_attachment;uid
pre_forum_attachment_0;uid
pre_forum_attachment_1;uid
pre_forum_attachment_2;uid
pre_forum_attachment_3;uid
pre_forum_attachment_4;uid
pre_forum_attachment_5;uid
pre_forum_attachment_6;uid
pre_forum_attachment_7;uid
pre_forum_attachment_8;uid
pre_forum_attachment_9;uid
pre_forum_attachment_unused;uid
pre_forum_collection;uid
pre_forum_collectioncomment;uid
pre_forum_collectionfollow;uid
pre_forum_collectioninvite;uid
pre_forum_collectionteamworker;uid
pre_forum_creditslog;uid
pre_forum_debate;uid
pre_forum_debatepost;uid
pre_forum_groupcreditslog;uid
pre_forum_groupinvite;uid
pre_forum_groupuser;uid
pre_forum_hotreply_member;uid
pre_forum_medallog;uid
pre_forum_modwork;uid
pre_forum_order;uid
pre_forum_polloption_image;uid
pre_forum_pollvoter;uid
pre_forum_post;authorid
pre_forum_postcomment;authorid
pre_forum_postlog;uid
pre_forum_post_location;uid
pre_forum_promotion;uid
pre_forum_ratelog;uid
pre_forum_spacecache;uid
pre_forum_thread;authorid
pre_forum_threadhidelog;uid
pre_forum_threadlog;uid
pre_forum_threadmod;uid
pre_forum_threadpartake;uid
pre_forum_trade;sellerid
pre_forum_tradelog;sellerid
pre_forum_tradelog;buyerid
pre_forum_warning;operatorid
pre_forum_warning;authorid
pre_home_album;uid
pre_home_appcreditlog;uid
pre_home_blacklist;uid
pre_home_blog;uid
pre_home_blogfield;uid
pre_home_class;uid
pre_home_clickuser;uid
pre_home_comment;uid
pre_home_comment;authorid
pre_home_docomment;uid
pre_home_doing;uid
pre_home_favorite;uid
pre_home_feed;uid
pre_home_feed_app;uid
pre_home_follow;uid
pre_home_follow;followuid
pre_home_follow_feed;uid
pre_home_follow_feed_archiver;uid
pre_home_friend;uid
pre_home_friend;fuid
pre_home_friendlog;uid
pre_home_friendlog;fuid
pre_home_friend_request;uid
pre_home_friend_request;fuid
pre_home_notification;uid
pre_home_notification;authorid
pre_home_pic;uid
pre_home_poke;uid
pre_home_poke;fromuid
pre_home_pokearchive;uid
pre_home_pokearchive;fromuid
pre_home_share;uid
pre_home_share;fromuid
pre_home_show;uid
pre_home_specialuser;uid
pre_home_specialuser;opuid
pre_home_userapp;uid
pre_home_visitor;uid
pre_home_visitor;vuid
pre_myrepeats;uid
pre_portal_article_title;uid
pre_portal_attachment;uid
pre_portal_category;uid
pre_portal_category_permission;uid
pre_portal_topic;uid
pre_portal_topic_pic;uid
pre_security_eviluser;uid
pre_security_failedlog;uid
pre_ucenter_admins;uid
pre_ucenter_feeds;uid
pre_ucenter_friends;uid
pre_ucenter_friends;friendid
pre_ucenter_memberfields;uid
pre_ucenter_members;uid
pre_ucenter_newpm;uid
pre_ucenter_pm_lists;authorid
pre_ucenter_pm_members;uid
pre_ucenter_pm_messages_0;authorid
pre_ucenter_pm_messages_1;authorid
pre_ucenter_pm_messages_2;authorid
pre_ucenter_pm_messages_3;authorid
pre_ucenter_pm_messages_4;authorid
pre_ucenter_pm_messages_5;authorid
pre_ucenter_pm_messages_6;authorid
pre_ucenter_pm_messages_7;authorid
pre_ucenter_pm_messages_8;authorid
pre_ucenter_pm_messages_9;authorid
pre_ucenter_protectedmembers;uid
更新UID程序框图
这里更新UID的方法,其实还是比较简单的,只需要使用更新的SQl语句即:update 表名 set UID键名=新UID值 where UID键名=旧UID值;
当然,这里是先得到有UID的表中的所有UID数据,然后循环处理这些UID,如果旧UID在Ucenter的member表中有值,则更新。如果Ucenter的member表中没有相应的值,则是以前删除了一些数据,还有遗留的,则删除这些冗余数据(delete语句),另外为了加快处理速度,如果新UID与旧UID是相同的,那就是没有变更,就不处理。
批量处理起来,还是比较耗时的,还算本论坛的数据量不大,总有效UID只有26000多个,170张表,大部分的内容都比较少,但是有几个表的数据量还是比较大的,像member会员、post回帖等相关的表,数据量都比较大。处理起来,最终花了一两个小时修改所有数据库。
当然,最开始其实是使用Ucenter的member表的UID来做for循环索引的,但是这样不能删除表中的冗余数据,而且UID比较多,但是很多表中没有相应的值,也需要去处理一次,那时候看其处理速度,估计需要二三十个小时,只能停止下来,放弃了那种方法。
|
|