0

我目前正在将我的concrete5.7 设置从本地主机移动到实时服务器。我做的第一件事是导出 SQL 数据库并将其导入服务器,但是这给了我一个错误:

Error
SQL query:

-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `config`
--
CREATE TABLE IF NOT EXISTS  `config` (

 `configNamespace` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL DEFAULT  '',
 `configGroup` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL ,
 `configItem` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL ,
 `configValue` LONGTEXT COLLATE utf8_unicode_ci,
PRIMARY KEY (  `configNamespace` ,  `configGroup` ,  `configItem` ) ,
KEY  `configGroup` (  `configGroup` )
) ENGINE = INNODB DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;

MySQL said: 

#1071 - Specified key was too long; max key length is 1000 bytes 

我知道密钥太长了,但有任何改变的自由吗?我尝试将数据库排序规则更改为 latin1,但它不起作用。

我可以更改哪些设置?

感谢您的任何反馈

4

2 回答 2

0

我会推荐以下结构:

CREATE TABLE IF NOT EXISTS  `config` (
    configId int not null auto_increment primary key,
    configNamespace VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL DEFAULT  '',
    configGroup VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL ,
    configItem VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL ,
    configValue LONGTEXT COLLATE utf8_unicode_ci,
    UNIQUE (configNamespace, configGroup,  configItem) ,   
    KEY  `configGroup` (  `configGroup` )
) ENGINE = INNODB DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;

这将为表创建自动递增的主键。此外,它保留了先前用于主键的三列的唯一约束。

于 2014-12-05T04:52:50.233 回答
0

这是一个糟糕的主键选择——你不需要 1000 字节的熵来使一行唯一 如果没有自然选择主键,你可以为该行生成一个代理键。

例如替换

 PRIMARY KEY (  `configNamespace` ,  `configGroup` ,  `configItem` ) ,

 configId INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

对于使用上述内容的应用程序,这不应该是重大更改。

于 2014-12-05T04:36:27.047 回答