如何使用drush site-upgrade升級Drupal 6到Drupal 7

ㄚ琪琪的家終於復歸了,但除了保存許多珍貴資料外,似乎還不能引人入勝,所以我們想改一下版型,卻發現很多都是需要Drupal 7的才可以安裝,一不做二不休,既然都復歸,就也來個升級吧。

這次的升級有了drush這個神兵利器,看來比較人性化了,否則Drupal有很大的進入障礙。一般都是用來小升級,要大升級的話,可能就得注意一下了,ㄚ琪這次參考的資料是Upgrade Drupal 6 to Drupal 7 using Drush site-upgrade,我們將它翻成中文,而且調整為適合我們的升級方式,這個升級的步驟很可能會因為每個人的Drupal 6安裝不同而產生很多的問題,像ㄚ琪這次在升級就碰到很多的問題,不過秉持著ㄚ琪MySQL多年的造詣,還是克服了升級的障礙,至於如何升級且聽我的分享。

當然我們要用drush的原因就是可以大量節省你升級Drupal 6的核心跟模組到Drupal7的核心跟模組,當然很可能你在drush site-upgrade後,你的網站會不能用,不過如果發生的話,接下來你還是可以搜尋手動升級模組的方法來做。

安裝最新版的Drush

2013-10-04_153551

 

上面的安裝方式室比較正式的,但因為我們使用的是Ubuntu系統,所以有更簡單的安裝方式:

pear channel-discover pear.drush.org

pear install drush/drush

drush

假如沒有問題,drush可以列出所有的功能選項,這樣就成功了第一步。

設定 drush aliases

現在我們需要告訴drush新的網站位置,drush不會覆蓋舊的網站,所以就算你升級失敗了,也不礙事的。現在要編輯aliases.drushrc.php這個檔。

vi /usr/local/share/drush/aliases.drushrc.php

注意,在Ubuntu是這樣:

vim /usr/share/php/drush/aliases.drushrc.php

因為我喜歡用vim,所以編輯的程式因人而異。

將下面的程式碼依需要複製貼上修改:

$aliases['newdrupalsite'] = array(
  'uri'  => 'localhost',
  'root' => '/absolute/path/to/your/new/drupal/site', // 這必須是完整的路徑,不是相對路徑喔
  'db-url' => 'mysql://DBUSER:DBPASS@localhost/DBNAME', //這是你新的資料庫名稱,還有帳號跟密碼,這是用來升級的
);

接著我們到舊網站的路徑去:

cd /location/of/drupal6/site
drush site-upgrade @newdrupalsite

好了,現在就照著指示做吧,這需要花一些時間,而且可能順利,也可能荊棘重重。

嗯,馬上就有問題了,你有可能缺少drush_sup這個專案,所以現在就下載吧:

drush dl drush_sup

再重新升級一次:

A Drupal site exists at the destination. What would you like to do?
[0] : Cancel
[1] : Re-use the existing code: re-import the database from the source
site and update core and contrib modules again.
[2] : Delete the existing target: start over from the beginning.

出現提示訊息,我是輸入1

Gathering information about core and contrib modules…

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 1

1. Check on the Drupal 7 status of your contributed and custom modules
and themes. See http://drupal.org/node/948216 for information on
upgrading contributed modules and themes. See
http://drupal.org/node/895314 for a list of modules that have been moved
into core for Drupal 7, and instructions on how to update them. See
http://drupal.org/update/modules for information on how to update your
custom modules, and http://drupal.org/update/theme for custom themes.

You may decide at this point that you cannot upgrade your site, because
needed modules or themes are not ready for Drupal 7.

There are no enabled contrib extensions; Drush will upgrade Drupal core.

Please review the upgread readiness report. You may want to uninstall modules that are not ready to upgrade yet.
[0] : Cancel
[1] : Begin upgrade

出現提示訊息後,我繼續選1

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 2

2. Update to the latest available version of Drupal 6.x (if your
current version is Drupal 5.x, you have to upgrade to 6.x first). If you
need to update, download Drupal 6.x and follow the instructions in its
UPGRADE.txt. This document only applies for upgrades from 6.x to 7.x.

You must also insure that all of your contrib modules are up to date!

Drupal core is up-to-date; version 6.28 installed.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 3

3. Log in as user ID 1 (the site maintenance user).

You will not need to log in if Drush is used to perform all upgrade
steps for you.

Skipping optional step.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 4

4. Go to Administer > Site configuration > Site maintenance. Select
“Off-line” and save the configuration.

When Drush does the steps of your site upgrade, it always modifies the
working copy of your site; the original site is left unchanged. You may
wish to take your site off-line anyway.

Skipping optional step.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 5

5. Go to Administer > Site building > Themes. Enable “Garland” and
select it as the default theme.

Drush will set the administrative theme to “Garland” in the target site
without affecting the source site.

Skipping optional step.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 6

6. Go to Administer > Site building > Modules. Disable all modules that
are not listed under “Core – required” or “Core – optional”. It is
possible that some modules cannot be disabled, because others depend on
them. Repeat this step until all non-core modules are disabled.

If you know that you will not re-enable some modules for Drupal 7.x and
you no longer need their data, then you can uninstall them under the
Uninstall tab after disabling them.

Drush will automatically disable all non-core modules in the target site
without affecting the source site. You may disable or uninstall contrib
modules now if you wish; any that you do not do now will be disabled by
Drush after Step 12.

Skipping optional step.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 7

7. On the command line or in your FTP client, remove the file

sites/default/default.settings.php

Drush will remove default.settings.php from the target site later, after
Step 12. You may remove it from the source sit now if you wish, but
doing so is unnecessary.

Skipping optional step.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 8

8. Remove all old core files and directories, except for the ‘sites’
directory and any custom files you added elsewhere.

If you made modifications to files like .htaccess or robots.txt, you
will need to re-apply them from your backup, after the new files are in
place.

Drush will create your upgraded site in a new location; it is not
necessary to remove any core files from the source site.

Skipping optional step.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 9

9. If you uninstalled any modules, remove them from the
sites/all/modules and other sites/*/modules directories. Leave other
modules in place, even though they are incompatible with Drupal 7.x.

Drush will create your upgraded site in a new location; it is not
necessary to remove any contrib module files from the source site.

Skipping optional step.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 10

10. Download the latest Drupal 7.x release from http://drupal.org to a
directory outside of your web root. Extract the archive and copy the
files into your Drupal directory.

On a typical Unix/Linux command line, use the following commands to
download and extract:

wget http://drupal.org/files/projects/drupal-x.y.tar.gz tar -zxvf
drupal-x.y.tar.gz

This creates a new directory drupal-x.y/ containing all Drupal files and
directories. Copy the files into your Drupal installation directory:

cp -R drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation

If you do not have command line access to your server, download the
archive from http://drupal.org using your web browser, extract it, and
then use an FTP client to upload the files to your web root.

Drush will automatically do this step now.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 11

11. Re-apply any modifications to files such as .htaccess or
robots.txt.

If you had no modifications to .htaccess or robots.txt, you don’t need
to do anything here.

Drush cannot do this step; you must perform it manually.

What would you like to do?
[0] : Cancel
[1] : I will do this step manually.
[2] : Skip this step.

很順利的進行到步驟11了,提示訊息出現後我輸入1

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 12

12. Make your settings.php file writeable, so that the update process
can convert it to the format of Drupal 7.x. settings.php is usually
located in

sites/default/settings.php

Note that Drush will instead *copy* your settings.php file to its new
location. The copy is made writable, but the original may remain
write-protected.

Drush will automatically do this step now.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 12-a

12-a. Drush-specific step: Drush will now do steps 5 and 6 of
UPGRADE.txt, and set the site theme to Garland and disable all contrib
modules. Before it does this, it makes a copy of your database, and does
all modifications on the *copy*, leaving your source site unchanged.
Drush will also uninstall all modules specified via the –uninstall
option at this time.

Drush will automatically do this step now.
No tables to drop. [ok]

You will destroy data in drupal7 and replace with data from drupal.

You might want to make a backup first, using the sql-dump command.

Do you really want to continue? (y/n): y
ERROR 1 (HY000) at line 25: Can’t create/write to file ‘/var/lib/mysql/新的資料庫名稱/access.MYI’ (Errcode: 2)

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 12-b

12-b. Drush-specific step: Drush will now do step 7 of UPGRADE.txt, and
remove sites/default/default.settings.php from the target site.

Drush will automatically do this step now.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 13

13. Run update.php by visiting http://www.example.com/update.php
(replace www.example.com with your domain name). This will update the
core database tables.

If you are unable to access update.php do the following:

– Open settings.php with a text editor.

– Find the line that says: $update_free_access = FALSE;

– Change it into: $update_free_access = TRUE;

– Once the upgrade is done, $update_free_access must be reverted to
FALSE.

Note that Drush will copy your database and run updatedb on the copy.
The source database remains unchanged.

Drush will automatically do this step now.
<h1>Additional uncaught exception thrown while handling exception.</h1><h2>Original</h2><p>PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &amp;#039;drupal7.system&amp;#039; doesn&amp;#039;t exist: SELECT name, schema_version FROM {system} WHERE type = :type; Array
(
[:type] =&amp;gt; module
)
in drupal_get_installed_schema_version() (line 155 of /新的網站路徑/includes/install.inc).</p><h2>Additional</h2><p>PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &amp;#039;drupal7.system&amp;#039; doesn&amp;#039;t exist: SELECT * FROM {system} WHERE type = &amp;#039;theme&amp;#039; OR (type = &amp;#039;module&amp;#039; AND status = 1) ORDER BY weight ASC, name ASC; Array
(
)
in system_list() (line 165 of /新的網站路徑/includes/module.inc).</p><hr />Drush command terminated abnormally due to an unrecoverable error.[error]
updatedb failed for core [error]

夠詭異吧,我想可能只有我會發生這個問題,我的空間不夠了,所以發生這樣的慘劇,馬上找顆硬碟來掛,重新升級。

.
.
.

這次碰到這樣的問題:

WD php: PDOException: SQLSTATE[42000]: Syntax error or access [error]
violation: 1071 Specified key was too long; max key length is 1000
bytes: ALTER TABLE {sessions} ADD PRIMARY KEY (`sid`, `ssid`);
Array
(
)
in db_add_primary_key() (line 2891 of
/新的網站路徑/includes/database/database.inc).
Drush command terminated abnormally due to an unrecoverable error.[error]
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: ALTER TABLE {sessions} ADD PRIMARY KEY (`sid`, `ssid`); Array
(
)
in db_add_primary_key() (line 2891 of /新的網站路徑/includes/database/database.inc).
updatedb failed for core [error]

這一類1071 Specified key was too long; max key length is 1000錯誤的訊息,好像超多人會有的,不過我看都沒有是sessions這個資料表的問題,後來從MySQL的錯誤觀點來看,我從新回去看Drupal6跟Drupal7這兩個資料庫,發現Drupal 7多加了ssid這個欄位,而且把sid跟ssid當成主鍵,這樣就有問題了,外國人可能不會有這個問題,但是華人用可能問題就大了,因為ㄚ琪原本的sid欄位的語系用utf8_general_ci,升級的時候ssid也會設成utf8_general_ci這樣的語系,sid原本是varchar(255),所以升級的時候,會多加ssid欄位,varchar(128),然後再改成主鍵,這樣子就會超過1000bytes,(255+128)*3 = 1149,所以我將sid的語系改成latin1_general_ci,再重新升級一次。

Cannot use a scalar value as an array locale.module:724             [warning]

.
.
.

都是這類的警告,不過不礙事。

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 14

14. Backup your database after the core upgrade has run.

Drush will automatically do this step now.
Making backup: ‘Upgraded Core’ in /root/.drush/cache/self-d6-to-drupal7-d7/progress_backups/upgraded-core.tar

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UPGRADE.txt Major Upgrade Step 15

15. Replace and update your non-core modules and themes, following the
procedures at http://drupal.org/node/948216

Drush will walk through these instructions for each module. Note that all
of the new modules will be downloaded up-front now; they will be moved
into place later.
Invalid argument supplied for foreach() upgrade.drush.inc:834 [warning]

There are no more modules to be upgraded.
[0] : Cancel
[1] : All done; finish upgrade

提示訊息後按1

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Upgrading Contrib Modules from Drupal 6 to Drupal 7 Finish Up

If you have a Drupal 7 version of the theme you were using for Drupal 6,
place it in sites/all/themes/ and reenable it.

Drush cannot do this step; you must perform it manually.

What would you like to do?
[0] : Cancel
[1] : I will do this step manually.

我再按1

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Post-upgrade Step A

A. Copy files directory from the source site to the upgrade site.

What would you like to do?
[0] : Cancel
[1] : Do it for me.
[2] : I will do this step manually.

這次我還是選1

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Post-upgrade Step B

B. Enable the core module content_migrate.

What would you like to do?
[0] : Cancel
[1] : Enable content migrate and show available migrations.
[2] : Do not enable the content migrate module.

我選2,這跟原文說的『Also when asked “Enable the core module content_migrate.” select “Do not enable the content migrate module”.』是一樣的。

我沒有碰到原文的問題,所以我就不轉貼了,如果朋友有新的問題,可以留言給我看看,看我能不能幫。

2013-10-04_131010

 

看看我的狀態報告,已經升級到7.23版了,Ya!

感謝你看到這裡,很快就可以離開了,但最好的獎勵行動就是按一下幫我分享或留言,感恩喔~

點我分享到Facebook

12 則留言

  1. UPGRADE.txt Major Upgrade Step 13
    和樓主碰上了一樣的問題 不過目前還是找不到問題在哪…
    似乎不是容量的問題

    1. Author

      你的錯誤訊息是什麼?或許可以一起研究一下。

      1. Take the ‘database’ record from the result and put it in your ‘dev’ alias. Put another ‘database’ record in your @stage alias definition; if you make sure that the values are correct, then you do not need to install drush on the remote machine.

        Additional uncaught exception thrown while handling exception.OriginalPDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wecosls.system' doesn't exist: SELECT name, schema_version FROM {system} WHERE type = :type; Array
        (
        [:type] =&gt; module
        )
        in drupal_get_installed_schema_version() (line 155 of /home/yunchen/sls/includes/install.inc).AdditionalPDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wecosls.system' doesn't exist: SELECT * FROM {system} WHERE type = 'theme' OR (type = 'module' AND status = 1) ORDER BY weight ASC, name ASC; Array
        (
        )
        in system_list() (line 165 of /home/yunchen/sls/includes/module.inc).Drush command terminated abnormally due to an unrecoverable error. [error]

        硬碟的話我想容量應該是足夠
        升級步驟也是按你的流程也操刀
        那drush在做小升級是ok的~ Drupal6也上至最新版
        現在就盡力在升級Drupal7囉

        1. 阿喔 第一段可以無視 我做筆記不小心多貼了一段(汗)

          1. Author

            你是指這一段嗎?
            Take the ‘database’ record from the result and put it in your ‘dev’ alias. Put another ‘database’ record in your @stage alias definition; if you make sure that the values are correct, then you do not need to install drush on the remote machine.

            不過我看到下一段的重要訊息:
            1146 Table ‘wecosls.system’ doesn’t exist: SELECT * FROM {system} WHERE type = ‘theme’ OR (type = ‘module’ AND status = 1) ORDER BY weight ASC, name ASC;
            可能是升級時新舊版本的資料表資料有問題,你可以檢查一下程式碼,比對一下用到的資料,做修改或許就可以正常了。

          2. 好 感謝提示 有結果我在來分享~

          3. 之前問的問題,先將網站用drush更新後(drush up)
            之後再upgrade這個問題就解掉了 中間出現不少狀況也一一處理
            最後碰上這個就沒頭緒了 就這麼短Orz
            SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://2_1.JPG’ for [error] key ‘uri’
            想問問你有什麼看法?

  2. Author

    是不是在uri這個欄位有重複的紀錄”public://2_1.JPG”,檢查一下這個資料表的用途,重設資料結構或是刪除重複記錄,應該就可以解決。

    1. 好喔! 我再詳細檢查一下!
      果然還是db的問題Orz 感謝: p

  3. 呼~ 最後我也升級成功了 只不過目前網站頁面還不能動XD
    在這邊附上一些我們這碰到的問題 & 解法 尚未完全整理好 排版不太優請見諒

    aliases.drushrc.php 我們是這樣設定才會過…
    ‘localhost’,
    ‘root’ => ‘yourroot’,
    ‘db-url’ => ‘mysqli://youraccount:password@localhost/dbname’,
    ‘databases’ =>
    array (
    ‘default’ =>
    array (
    ‘default’ =>
    array (
    ‘driver’ => ‘mysql’,
    ‘username’ => ‘yourusername’,
    ‘password’ => ‘yourpassword’,
    ‘port’ => ”,
    ‘host’ => ‘localhost’,
    ‘database’ => ‘yournewdbname’,
    ),
    ),
    ),
    );
    ?>

    Q0:
    12-a
    Unknown option: –uninstall. See `drush help pm-disable` for [error]
    available options. To suppress this error, add the option –strict=0.

    A0:
    sudo cp /usr/share/php/drush/example/example.drushrc.php ~/.drush/drushrc.php
    sudo vim ~/.drush/drushrc.php
    補上最後一行 $command_specific[‘pm-disable’] = array(‘strict’ => 0);

    Q1:
    SQLSTATE[42S02]: Base table or view not found: 1146 Table [error]
    ‘wecosls.watchdog’ doesn’t exist

    A1:
    到 sls 資料庫中建資料表

    mysql -u root -p
    mysql>use yourdbname;
    mysql>CREATE TABLE `watchdog` (
    `wid` int(11) NOT NULL auto_increment,
    `uid` int(11) NOT NULL default ‘0’,
    `type` varchar(16) NOT NULL default ”,
    `message` longtext NOT NULL,
    `variables` longtext NOT NULL,
    `severity` tinyint(3) unsigned NOT NULL default ‘0’,
    `link` varchar(255) NOT NULL default ”,
    `location` text NOT NULL,
    `referer` varchar(128) NOT NULL default ”,
    `hostname` varchar(128) NOT NULL default ”,
    `timestamp` int(11) NOT NULL default ‘0’,
    PRIMARY KEY (`wid`),
    KEY `type` (`type`)
    ) DEFAULT CHARSET=utf8;

    Q2:

    WD php: PDOException: SQLSTATE[42S02]: Base table or view not found: [error]
    1146 Table ‘wecosls.profile_field’ doesn’t exist: SELECT f.name,
    f.type, v.uid, v.value FROM {profile_field} f INNER JOIN
    {profile_value} v ON f.fid = v.fid WHERE uid IN (:uids_0); Array
    (
    [:uids_0] => 0
    )
    in profile_user_load() (line 254 of
    /home/sls/wecosls/modules/profile/profile.module).
    PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'we cosls.profile_field' doesn't exist: SELECT f.name, f.type, v.uid, v.va lue FROM {profile_field} f INNER JOIN {profile_value} v ON f.fid = v.fid WHERE u id IN (:uids_0); Array
    (
    [:uids_0] => 0
    )
    in profile_user_load() (line 254 of /home/sls/wecosls/modules/profile/profile.m odule).

    A2:

    到 sls 資料庫中 重新命名 profile_fields 資料表

    mysql -u root -p
    mysql>use yourdbname;
    mysql>RENAME TABLE sls.profile_fields TO sls.profile_field;
    mysql>exit

    Q3 :
    [ok]
    WD php: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table [error]
    ‘wecosls.profile_value’ doesn’t exist: SELECT f.name, f.type, v.uid, v.value FROM
    {profile_field} f INNER JOIN {profile_value} v ON f.fid = v.fid WHERE uid IN (:uids_0); Array
    (
    [:uids_0] => 0
    )
    in profile_user_load() (line 254 of /home/sls/wecosls/modules/profile/profile.module).
    PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wecosls.profile_value' doesn't exist: SELECT f.name, f.type, v.uid, v.value FROM {profile_field} f INNER JOIN {profile_value} v ON f.fid = v.fid WHERE uid IN (:uids_0); Array
    (
    [:uids_0] => 0
    )
    in profile_user_load() (line 254 of /home/sls/wecosls/modules/profile/profile.module).

    A3 :

    到 sls 資料庫中 重新命名 profile_values 資料表

    mysql -u root -p
    mysql>use yourdbname;
    mysql>RENAME TABLE sls.profile_values TO sls.profile_value;
    mysql>exit

    Q4:

    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://2_1.JPG’ for [error]
    key ‘uri’

    A4:

    參考資料 : https://www.drupal.org/node/1260938

    mysql -u root -p
    mysql>use yourdbname;
    mysql>CREATE TABLE tmp SELECT * FROM files GROUP BY filepath, filename;
    mysql>DROP TABLE files;
    mysql>ALTER TABLE tmp RENAME TO files;

    Q5:
    找不到 sls.profile_fields 的table

    A5:

    mysql -u root -p
    mysql>use yourdbname;
    mysql>RENAME TABLE sls.profile_field TO sls.profile_fields;
    mysql>exit

    Q6:
    找不到 sls.profile_values 的table

    A6:

    mysql -u root -p
    mysql>use yourdbname;
    mysql>RENAME TABLE sls.profile_value TO sls.profile_values;
    mysql>exit

    Q7:

    Cannot change the definition of field accesslog.sid: field doesn’t exist.

    A7:

    mysql>CREATE TABLE IF NOT EXISTS `accesslog` (
    `aid` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘Primary Key: Unique accesslog ID.’,
    `sid` varchar(128) NOT NULL DEFAULT ” COMMENT ‘Browser session ID of user that visited page.’,
    `title` varchar(255) DEFAULT NULL COMMENT ‘Title of page visited.’, `path` varchar(255) DEFAULT NULL COMMENT ‘Internal path to page visited (relative to Drupal root.)’,
    `url` text COMMENT ‘Referrer URI.’,
    `hostname` varchar(128) DEFAULT NULL COMMENT ‘Hostname of user that visited the page.’,
    `uid` int(10) unsigned DEFAULT ‘0’ COMMENT ‘User users.uid that visited the page.’,
    `timer` int(10) unsigned NOT NULL DEFAULT ‘0’ COMMENT ‘Time in milliseconds that the page took to load.’,
    `timestamp` int(10) unsigned NOT NULL DEFAULT ‘0’ COMMENT ‘Timestamp of when the page was visited.’,
    PRIMARY KEY (`aid`),
    KEY `accesslog_timestamp` (`timestamp`),
    KEY `uid` (`uid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=’Stores site access information for statistics.’ AUTO_INCREMENT=1 ;

    Q8:

    SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘wecosls.search_index’ doesn’t exist

    A8:

    mysql>CREATE TABLE IF NOT EXISTS `search_index` (
    `word` varchar(50) NOT NULL default ”,
    `sid` int(10) unsigned NOT NULL default ‘0’,
    `type` varchar(16) default NULL,
    `fromsid` int(10) unsigned NOT NULL default ‘0’,
    `fromtype` varchar(16) default NULL,
    `score` float default NULL,
    KEY `sid_type` (`sid`,`type`),
    KEY `from_sid_type` (`fromsid`,`fromtype`),
    KEY `word` (`word`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;


發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *