很多站長突然發現自己的站開啟報錯 1146,就不知道該怎麼辦了,最常見的報錯表是以下 2 個:
[1146] Table 'sqla1212142518.common_session' doesn't exist
[1146] Table 'sqlshou277.common_cron' doesn't exist
其實你認不認識這些英語沒關係,只要知道大概什麼意思就行,下面我解釋下:
Table:資料表。
sqla1212142518 /sqlshou277: 這 2 個是資料庫名,一般就是自己的資料庫,記住在單引號開頭的是資料庫名就行。
common_session/common_cron:這 2 個是資料表,也就是需要重建的表。
doesn't exist:不存在。如果不認識這 2 個單詞可以使用線上翻譯。
知道這些了就容易了,哪個表不存在就重建哪個,當然這 2 個表裡沒有重要資料,重建就行,如果是 member 或者 post 表不存在那就得恢復資料了,否則就會導致沒有會員或者帖子。
首先下載和自己論壇版本對應的標準程式,解壓之後,開啟 upload/install/data/install.sql 的檔案。 CTRL+F 搜尋報錯的表名 common_session 。找到建表語句,如:
- DROP TABLE IF EXISTS pre_common_session;
- CREATE TABLE pre_common_session (
- sid char(6) NOT NULL DEFAULT '',
- ip1 tinyint(3) unsigned NOT NULL DEFAULT '0',
- ip2 tinyint(3) unsigned NOT NULL DEFAULT '0',
- ip3 tinyint(3) unsigned NOT NULL DEFAULT '0',
- ip4 tinyint(3) unsigned NOT NULL DEFAULT '0',
- uid mediumint(8) unsigned NOT NULL DEFAULT '0',
- username char(15) NOT NULL DEFAULT '',
- groupid smallint(6) unsigned NOT NULL DEFAULT '0',
- invisible tinyint(1) NOT NULL DEFAULT '0',
- `action` tinyint(1) unsigned NOT NULL DEFAULT '0',
- lastactivity int(10) unsigned NOT NULL DEFAULT '0',
- lastolupdate int(10) unsigned NOT NULL DEFAULT '0',
- fid mediumint(8) unsigned NOT NULL DEFAULT '0',
- tid mediumint(8) unsigned NOT NULL DEFAULT '0',
- UNIQUE KEY sid (sid),
- KEY uid (uid)
- ) TYPE=HEAP;
其實第一行可以不要,不過無所謂,這句程式碼的意思是如果這個表存在則刪除,反正已經沒有了。
注意:如果你的表字首不是預設的 pre_,那麼需要把建表語句的 pre_替換成你正在用的表字首。
複製建表語句,進入 phpmyadmin,隨便點一個表,點選 SQL,貼上建表語句,點執行即可。