Discuz 3.2, 3.3, 3.4 直接利用SQL创建新用户

我们的网站要和Discuz整合到一起,有个新用户同步的需求,网络上很多的做法是用 UCenter的接口来做,反正最后都是插入SQL,笔者使用了直接操作数据库的方式,把操作的表和SQL整理了下,后面如果有时间做个SSO就省事了

版本:dz 3.2版本 ucenter1.6版本
目标:插入普通用户,最小可用就行了,可以登录

SQL记录:

注意:表名称前缀根据配置可能不同, 一共有8张表

SELECT *FROM pre_ucenter_members;
-- UCenter用户数据表 uid, username, password, email, regip(默认写一个值), regdate(时间戳), salt(随机6位字母数字)

SELECT *FROM pre_ucenter_memberfields;
-- UCenter用户扩展信息数据表 插入 uid

SELECT *FROM pre_common_member;
-- 主用户表 插入的字段 email, username, password, emailstatus, regdate(时间戳)
-- 得到uid再插入其它表

SELECT *FROM pre_common_member_count;
-- 用户数据统计 各种积分,动态等 插入 uid

SELECT *FROM pre_common_member_field_forum;
-- 用户论坛设置数据表 插入 uid

SELECT *FROM pre_common_member_field_home;
-- 用户家园设置数据表 插入 uid

SELECT *FROM pre_common_member_profile;
-- 用户个人资料数据表 插入 uid

SELECT *FROM pre_common_member_status;
-- 用户状态数据表 插入 uid


-- 下面是插入一个普通用户的测试, 这里根据id自增,自己算出了uid,便于sql书写 
-- lzz, 邮箱 [email protected], 密码 xyz2541 
-- 需要计算的密码 pre_common_member 密码为 md5(password) 2cf5c897f58ca21cac9bec93f46f6f53
-- pre_ucenter_members salt yyy111 密码为 md5(md5(password)+salt) 4fab791987738fce5f11504a0fe2a342
-- MYSQL mode 设置的比较严格,所以很多默认值要自己加上。。

INSERT INTO pre_ucenter_members SET uid=7, username='lzz', `password`='4fab791987738fce5f11504a0fe2a342', email='[email protected]', regip='127.0.0.1', regdate=UNIX_TIMESTAMP(), salt='yyy111';

INSERT INTO pre_ucenter_memberfields SET uid=7, blacklist='';

INSERT INTO pre_common_member SET uid=7, username='lzz', `password`='2cf5c897f58ca21cac9bec93f46f6f53', email='[email protected]', emailstatus=1, regdate=UNIX_TIMESTAMP();

INSERT INTO pre_common_member_count SET uid=7;

INSERT INTO pre_common_member_field_forum SET uid=7, `medals`='', `sightml`='', `groupterms`='', `groups`='';

INSERT INTO pre_common_member_field_home SET uid=7, `spacecss`='', `blockposition`='', 
`recentnote`='', `spacenote`='', `privacy`='', `feedfriend`='', `acceptemail`='', `magicgift`='', `stickblogs`='';

INSERT INTO pre_common_member_profile SET uid=7, `bio`='', `interest`='', `field1`='', `field2`='',
`field3`='', `field4`='', `field5`='', `field6`='', `field7`='', `field8`='';

INSERT INTO pre_common_member_status SET uid=7;

在Discuz的数据库中插入到数据库之后,web端就能登录了

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.