翻譯成 Translate to... English | 繁體中文 | 简体中文

Specified key was too long; max key length is 1000 bytes (MediaWiki 1.10.0)

解決方式: 修改以下三個檔案,將varchar由255改成160
maintenance/tables.sql

- cl_to varchar(255) binary NOT NULL default '',
+ cl_to varchar(160) binary NOT NULL default '',

- job_cmd varchar(255) NOT NULL default '',
+ job_cmd varchar(160) NOT NULL default '',

- job_title varchar(255) binary NOT NULL,
+ job_title varchar(160) binary NOT NULL,

- pr_type varchar(255) NOT NULL,
+ pr_type varchar(160) NOT NULL,

- pr_level varchar(255) NOT NULL,
+ pr_level varchar(160) NOT NULL,


maintenance/archives/patch-categorylinks.sql

- cl_to varchar(255) binary NOT NULL default '',
+ cl_to varchar(160) binary NOT NULL default '',


maintenance/archives/patch-job.sql

- job_cmd varchar(255) NOT NULL default '',
+ job_cmd varchar(160) NOT NULL default '',

- job_title varchar(255) binary NOT NULL,
+ job_title varchar(160) binary NOT NULL,


問題狀況:
為了讓phpMyAdmin可以順利看到中文,而不會是亂碼。新增一資料庫wikidb(utf8_unicode_ci)供MediaWiki 1.10.0使用,資料庫編碼設定(Database charset)選擇 Experimental MySQL 4.1/5.0 UTF-8,在安裝時遭遇錯誤訊息

Creating hitcounter table...ok
Creating querycache table...ok
Creating objectcache table...ok
Creating categorylinks table...Query "CREATE TABLE `categorylinks` (
cl_from int(8) unsigned NOT NULL default '0',
cl_to varchar(255) binary NOT NULL default '',
cl_sortkey varchar(86) binary NOT NULL default '',
cl_timestamp timestamp NOT NULL,
UNIQUE KEY cl_from(cl_from,cl_to),
KEY cl_sortkey(cl_to,cl_sortkey),
KEY cl_timestamp(cl_to,cl_timestamp)
) ENGINE=InnoDB, DEFAULT CHARSET=utf8
" failed with error code "Specified key was too long; max key length is 1000 bytes (localhost)".

伺服器環境: XAMPP 1.6.2 (Apache/2.2.4 (Win32) PHP/5.2.2 MySQL/5.0.41 phpMyAdmin/2.10.1)

參考資料:

留言

  1. 有相同的问题,以前没注意数据库是latin1的,想转成UTF8不行了

    回覆刪除

張貼留言

如果要直接聯絡我,請點選左側上方漢堡選單,填寫其中的聯絡我表單~

facebook page