Discuz常用sql语句

搜集了一些常用的sql语句。

此操作有风险!升级前请备份好数据库!!

UPDATE `cdb_forums` SET `allowtag` = '1';

allowtag参数有:0=关闭 1=使用 2=使用且自动生成。均指所有版块

UPDATE `cdb_forums` SET `allowpostspecial` = '31'
所有板块的特殊主题开启

UPDATE `cdb_members` SET `groupid` = '10' WHERE groupid='8';
批量删除等待验证用户

UPDATE `cdb_forums` SET `allowmediacode` = '1'
所有板块开启media代码

update cdb_settings set value = 120 WHERE variable = 'maxavatarpixel'
调整所有用户最大头像尺寸(像素)为120

UPDATE  cdb_threads SET  closed  = 1  WHERE  fid =20 ;
一次性关闭板块fid20帖子

update cdb_members set groupid = * where posts = 0;
把发帖数为0的用户都转到某个用户组

UPDATE `cdb_usergroups` SET `allowinvite` = '1', `inviteprice` = '价格';
开启全部用户组的邀请注册权限 并设置价格

replace INTO cdb_settings VALUES ('watermarktype','0');
去除水印图片类型

update cdb_members set lastpost='1186675200';
调整用户最后登录时间为 2007年8月10日

UPDATE `cdb_forums` SET `status` = '0'  WHERE `cdb_forums`.`fid` =6 LIMIT 1 ;
调整`fid` =6板块隐藏的sql!

update cdb_threads set fid=B板块ID,typeid=c分类的ID where fid=A板块ID;
update cdb_posts set fid=B板块ID where fid=A板块ID;
将A板块的所有帖子转到B板块的C分类里
执行前备份一下数据库
UPDATE `cdb_settings` SET `value` = '' WHERE CONVERT( `variable` USING utf8 ) ='adminipaccess' LIMIT 1 ;
去除后台管理员ip登录限制

delete from cdb_styles where styleid=5 limit 1;
删除风格5

UPDATE `cdb_members` SET `pmsound` = '1'
论坛所有用户短消息提示音修改为提示音1

delete from cdb_usergroups where groupid = 0
删除groupid = 0的用户组

UPDATE `cdb_forums` SET `alloweditpost` = '1'
所有板块开启允许编辑帖子

delete from cdb_settings where variable='insenz'
论坛后台 解除insenz绑定语句
论坛后台执行后 就可以 重新注册和绑定了

update cdb_forumfields set viewperm ='t允许浏览的用户组的IDt' where fid in(论坛板块ID)
如:
update cdb_forumfields set viewperm ='t1t2t' where fid in(1,2)
关闭游客浏览所有版块的语句

UPDATE `cdb_forumfields` SET `rules` = '板块规则'
所有板块的板块规则设置~!

UPDATE `cdb_forums` SET `jammer` = '1'
开启所有板块的干扰码

UPDATE cdb_usergroups SET allowinvite=1, allowmailinvite=1, maxinvitenum=10, maxinviteday=15, inviteprice=10;
开启所有会员组邀请注册的权限

//allowinvite 允许使用邀请注册:
//allowmailinvite 允许发送邀请注册:
//maxinvitenum 24小时内购买邀请码最大数量:
//maxinviteday 邀请码有效期:
//inviteprice 邀请码购买价格:

UPDATE `cdb_settings` SET `value` = '昨日发帖数 最高日发帖数' WHERE `variable` ='historyposts' LIMIT 1 ;
修改最高日发帖数

'昨日发帖数 最高日发帖数' 中间的空格是tab键~!
昨日发帖数 和 最高日发帖数 修改为你需要的数字即可, 升级完sql后,更新缓存

UPDATE `cdb_settings` SET `value` = '0' WHERE CONVERT( `variable` USING utf8 ) = 'gzipcompress' LIMIT 1 ;
关闭论坛的gzip设置!
update cdb_members set adminid='-1', groupid='4' where groupid='?';
批量对用户组禁言

delete from cdb_threads where authorid=0;
delete from cdb_posts where authorid=0;
批量删除游客组的发帖和主题

update cdb_members set credits=0,extcredits1=0,extcredits2=0,extcredits3=0,extcredits4=0,extcredits5=0,extcredits6=0,extcredits7=0,extcredits8=0 where uid > 2000 and uid < 3000; uid 2000~3000的会员全部积分清零 update cdb_posts set invisible = 0 where tid > 最小的tid and tid < 最大的 tid 指定范围内的审核帖子通过审核 update cdb_threads set displayorder=0 where tid > 最小的 tid and tid < 最大的 tid
指定范围内的审核主题通过审核

delete from cdb_threads where displayorder=-2;
delete from cdb_posts where invisible=-2;
批量删除未审核通过的帖子和主题

UPDATE cdb_threads SET closed = 1 WHERE special=1
批量关闭投票

UPDATE `cdb_members` SET `secques` = ''
清空用户安全问答!

update cdb_members set credits = 0, extcredits1 = 0, extcredits2 = 0, extcredits3 = 0, extcredits4 = 0, extcredits5 = 0, extcredits6 = 0, extcredits7 = 0, extcredits8 = 0, where groupid = 用户组id;
清空某个用户组的全部积分

update cdb_usergroups set allowtransfer=0
关闭所有用户组的积分转账

update cdb_threads set readperm=100 where dateline<1133300000
修改05年11月29日21点33份20秒 前的主题阅读权限100
其中1133300000 是unix时间戳 (以秒为单位) 代表 05年11月29日21点33份20秒
readperm=100 代表阅读权限

update cdb_threads set readperm=100 where dateline<1104537600 and digest=0
把2005年1月1日以前的阅读权限设高.

update cdb_ratelog set uid = '新uid', username = '新username' where uid = '旧的 uid';
批量替换帖子里面的评分者的用户名

update cdb_attachments set readperm=1
所有的附件默认阅读权限为1

SELECT count(`extcredits1`) FROM `cdb_members` where `posts`=0
统计发帖量大于0的所有用户积分1的总量

UPDATE `cdb_members` SET `showemail` ='1' WHERE `uid` in(1,2,3,4,5,6);
批量修改uid1~6会员的 showemail 为 1

update cdb_members set extcredits1=extcredits1+extcredits2;
update cdb_members set extcredits1='0';
将积分1加到积分2上 并清零积分1

update cdb_members set adminid=-1,groupid=特殊用户组ID where lastactivity< unix_timestamp()-300*24*3600
把300天未登录的ID移到某一特殊用户组

delete from cdb_forums where fid=1 limit 1;
删除fid=1的板块

Leave a Reply