很多站長突然發現自己的站打開報錯 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 。找到建表語句,如:

  1. DROP TABLE IF EXISTS pre_common_session;
  2. CREATE TABLE pre_common_session (
  3.   sid char(6) NOT NULL DEFAULT '',
  4.   ip1 tinyint(3) unsigned NOT NULL DEFAULT '0',
  5.   ip2 tinyint(3) unsigned NOT NULL DEFAULT '0',
  6.   ip3 tinyint(3) unsigned NOT NULL DEFAULT '0',
  7.   ip4 tinyint(3) unsigned NOT NULL DEFAULT '0',
  8.   uid mediumint(8) unsigned NOT NULL DEFAULT '0',
  9.   username char(15) NOT NULL DEFAULT '',
  10.   groupid smallint(6) unsigned NOT NULL DEFAULT '0',
  11.   invisible tinyint(1) NOT NULL DEFAULT '0',
  12.   `action` tinyint(1) unsigned NOT NULL DEFAULT '0',
  13.   lastactivity int(10) unsigned NOT NULL DEFAULT '0',
  14.   lastolupdate int(10) unsigned NOT NULL DEFAULT '0',
  15.   fid mediumint(8) unsigned NOT NULL DEFAULT '0',
  16.   tid mediumint(8) unsigned NOT NULL DEFAULT '0',
  17.   UNIQUE KEY sid (sid),
  18.   KEY uid (uid)
  19. ) TYPE=HEAP;

其實第一行可以不要,不過無所謂,這句代碼的意思是如果這個表存在則刪除,反正已經沒有了。

注意:如果你的表前綴不是默認的 pre_,那麼需要把建表語句的 pre_替換成你正在用的表前綴。
複製建表語句,進入 phpmyadmin,隨便點一個表,點擊 SQL,粘貼建表語句,點執行即可。