discuz出现表不存在错误:(1146)Table‘discuz.forum_pos...
2023-07-04 09:30阅读:
安装成功后发帖报错:
(1146) Table ‘discuz.forum_post’ doesn’t exist
SELECT * FROM forum_post WHERE
authorid=‘2’ AND
invisible=’-3’ AND
first=‘1’ LIMIT 20
后来一查原来是pre_forum_post 建表失败了.报错如下:
[Err] 1064 - You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax
to use near ‘TYPE=MyISAM’ at line 36
大致意思就是语法问题不支持TYPE=MyISAM
然后我有改成ENGINE=MyISAM,还是报错,不过这次报错不一样了,错误信息如下:
[Err] 1075 - Incorrect table definition; there can be only one auto
column and it must be defined as a key
表定义不正确;只能有一个auto列,必须将其定义为键
pr
e_forum_post 原表结构:
CREATE
TABLE pre_forum_post ( pid
int(10) unsigned NOT NULL, fid
mediumint(8) unsigned NOT
NULL DEFAULT '0', tid
mediumint(8) unsigned NOT
NULL DEFAULT '0', `first` tinyint(1) NOT
NULL DEFAULT '0', author
varchar(15) NOT NULL DEFAULT
'', authorid
mediumint(8) unsigned NOT
NULL DEFAULT '0', `subject` varchar(80)
NOT NULL DEFAULT '', dateline
int(10) unsigned NOT NULL
DEFAULT '0', message mediumtext NOT NULL, useip
varchar(15) NOT NULL DEFAULT
'', `port` smallint(6) unsigned NOT NULL
DEFAULT '0', invisible
tinyint(1) NOT NULL DEFAULT
'0', anonymous
tinyint(1) NOT NULL DEFAULT
'0', usesig
tinyint(1) NOT NULL DEFAULT
'0', htmlon
tinyint(1) NOT NULL DEFAULT
'0', bbcodeoff
tinyint(1) NOT NULL DEFAULT
'0', smileyoff
tinyint(1) NOT NULL DEFAULT
'0', parseurloff
tinyint(1) NOT NULL DEFAULT
'0', attachment
tinyint(1) NOT NULL DEFAULT
'0', rate
smallint(6) NOT NULL DEFAULT
'0', ratetimes
tinyint(3) unsigned NOT NULL
DEFAULT '0', `status`
int(10) NOT NULL DEFAULT
'0', tags
varchar(255) NOT NULL
DEFAULT '0', `comment` tinyint(1) NOT
NULL DEFAULT '0', replycredit
int(10) NOT NULL DEFAULT
'0', position
int(8) unsigned NOT NULL
AUTO_INCREMENT, PRIMARY KEY
(tid,position), UNIQUE KEY pid
(pid), KEY fid (fid), KEY
authorid (authorid,invisible), KEY
dateline (dateline), KEY
invisible (invisible), KEY
displayorder (tid,invisible,dateline),
KEY `first` (tid,`first`) ) TYPE=MyISAM;
更改后表结构:
修改点:
PRIMARY KEY (tid,position), ===》 PRIMARY KEY
(position),
然后就是MySQL引擎的变化,TYPE=MyISAM; ==》 ENGINE=InnoDB DEFAULT
CHARSET=utf8;
CREATE
TABLE `pre_forum_post` ( `pid` int(10)
unsigned NOT NULL, `fid` mediumint(8) unsigned NOT
NULL DEFAULT '0', `tid` mediumint(8)
unsigned NOT NULL DEFAULT '0', `first`
tinyint(1) NOT NULL DEFAULT '0', `author`
varchar(15) NOT NULL DEFAULT '',
`authorid` mediumint(8) unsigned NOT NULL DEFAULT
'0', `subject` varchar(80) NOT NULL
DEFAULT '', `dateline`
int(10) unsigned NOT NULL DEFAULT
'0', `message` mediumtext NOT NULL, `useip`
varchar(15) NOT NULL DEFAULT '', `port`
smallint(6) unsigned NOT NULL DEFAULT
'0', `invisible` tinyint(1) NOT NULL
DEFAULT '0', `anonymous` tinyint(1) NOT
NULL DEFAULT '0', `usesig` tinyint(1) NOT
NULL DEFAULT '0', `htmlon` tinyint(1) NOT
NULL DEFAULT '0', `bbcodeoff` tinyint(1)
NOT NULL DEFAULT '0', `smileyoff`
tinyint(1) NOT NULL DEFAULT '0',
`parseurloff` tinyint(1) NOT NULL DEFAULT
'0', `attachment` tinyint(1) NOT NULL
DEFAULT '0', `rate` smallint(6) NOT NULL
DEFAULT '0', `ratetimes` tinyint(3)
unsigned NOT NULL DEFAULT '0', `status`
int(10) NOT NULL DEFAULT
'0', `tags` varchar(255) NOT NULL DEFAULT
'0', `comment` tinyint(1) NOT NULL
DEFAULT '0', `replycredit`
int(10) NOT NULL DEFAULT
'0', `position` int(8)
unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY
(`position`), UNIQUE KEY `pid` (`pid`), KEY `fid`
(`fid`), KEY `authorid` (`authorid`,`invisible`), KEY `dateline`
(`dateline`), KEY `invisible` (`invisible`), KEY `displayorder`
(`tid`,`invisible`,`dateline`), KEY `first` (`tid`,`first`) )
ENGINE=InnoDB DEFAULT CHARSET=utf8;
pre_common_member_grouppm消息建表失败,表结构如下
CREATE TABLE pre_common_member_grouppm
( uid MEDIUMINT (8) UNSIGNED NOT
NULL DEFAULT '0', gpmid
SMALLINT (6) UNSIGNED NOT
NULL AUTO_INCREMENT, `status` TINYINT (1)
NOT NULL DEFAULT
'0', dateline INT (10)
UNSIGNED NOT NULL DEFAULT
'0', PRIMARY KEY (uid, gpmid) ) ENGINE
= MYISAM DEFAULT CHARSET =
utf8;
更改后:
CREATE TABLE pre_common_member_grouppm
( uid MEDIUMINT (8) UNSIGNED NOT
NULL DEFAULT '0', gpmid
SMALLINT (6) UNSIGNED NOT
NULL AUTO_INCREMENT, `status` TINYINT (1)
NOT NULL DEFAULT
'0', dateline INT (10)
UNSIGNED NOT NULL DEFAULT
'0', PRIMARY KEY (gpmid) )
ENGINE=InnoDB DEFAULT CHARSET
= utf8;