并将所有有auto_increment 属性的,加为KEY。
如 id 有auto_increment属性,则在相应段加上一行 KEY `id` (`id`), (如果已有完全相同这一行就不要加)
以下是这次解决问题过程,没兴趣的可不看:
1.常规安装,然后导出数据库,修改默认字符集
sed -i '/DEFAULT CHARSET=utf8[^m]/s/DEFAULT CHARSET=utf8/&mb4/' bbs.sql
2.使用ENGINE=MyISAM ,如果直接导入bbs.sql,会出错,提示如下:
ERROR 1071 (42000) at line 104: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 115: Table 'bbs.pre_common_admincp_perm' doesn't exist
ERROR 1146 (42S02) at line 116: Table 'bbs.pre_common_admincp_perm' doesn't exist
ERROR 1146 (42S02) at line 117: Table 'bbs.pre_common_admincp_perm' doesn't exist
ERROR 1146 (42S02) at line 118: Table 'bbs.pre_common_admincp_perm' doesn't exist
ERROR 1071 (42000) at line 631: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 643: Table 'bbs.pre_common_cache' doesn't exist
ERROR 1146 (42S02) at line 644: Table 'bbs.pre_common_cache' doesn't exist
ERROR 1146 (42S02) at line 645: Table 'bbs.pre_common_cache' doesn't exist
ERROR 1071 (42000) at line 655: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 677: Table 'bbs.pre_common_card' doesn't exist
ERROR 1146 (42S02) at line 678: Table 'bbs.pre_common_card' doesn't exist
ERROR 1146 (42S02) at line 679: Table 'bbs.pre_common_card' doesn't exist
ERROR 1071 (42000) at line 1831: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 1857: Table 'bbs.pre_common_member_profile_setting' doesn't exist
ERROR 1146 (42S02) at line 1858: Table 'bbs.pre_common_member_profile_setting' doesn't exist
ERROR 1146 (42S02) at line 1859: Table 'bbs.pre_common_member_profile_setting' doesn't exist
ERROR 1146 (42S02) at line 1860: Table 'bbs.pre_common_member_profile_setting' doesn't exist
ERROR 1071 (42000) at line 1870: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 1888: Table 'bbs.pre_common_member_security' doesn't exist
ERROR 1146 (42S02) at line 1889: Table 'bbs.pre_common_member_security' doesn't exist
ERROR 1146 (42S02) at line 1890: Table 'bbs.pre_common_member_security' doesn't exist
ERROR 1071 (42000) at line 2673: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 2684: Table 'bbs.pre_common_setting' doesn't exist
ERROR 1146 (42S02) at line 2685: Table 'bbs.pre_common_setting' doesn't exist
ERROR 1146 (42S02) at line 2686: Table 'bbs.pre_common_setting' doesn't exist
ERROR 1146 (42S02) at line 2687: Table 'bbs.pre_common_setting' doesn't exist
ERROR 1071 (42000) at line 4800: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 4816: Table 'bbs.pre_forum_groupfield' doesn't exist
ERROR 1146 (42S02) at line 4817: Table 'bbs.pre_forum_groupfield' doesn't exist
ERROR 1146 (42S02) at line 4818: Table 'bbs.pre_forum_groupfield' doesn't exist
ERROR 1071 (42000) at line 7101: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 7120: Table 'bbs.pre_home_favorite' doesn't exist
ERROR 1146 (42S02) at line 7121: Table 'bbs.pre_home_favorite' doesn't exist
ERROR 1146 (42S02) at line 7122: Table 'bbs.pre_home_favorite' doesn't exist
ERROR 1071 (42000) at line 7797: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 7808: Table 'bbs.pre_mobile_setting' doesn't exist
ERROR 1146 (42S02) at line 7809: Table 'bbs.pre_mobile_setting' doesn't exist
ERROR 1146 (42S02) at line 7810: Table 'bbs.pre_mobile_setting' doesn't exist
ERROR 1146 (42S02) at line 7811: Table 'bbs.pre_mobile_setting' doesn't exist
ERROR 1071 (42000) at line 8567: Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02) at line 8582: Table 'bbs.pre_ucenter_badwords' doesn't exist
ERROR 1146 (42S02) at line 8583: Table 'bbs.pre_ucenter_badwords' doesn't exist
ERROR 1146 (42S02) at line 8584: Table 'bbs.pre_ucenter_badwords' doesn't exist
处理方法1:
-----------------
根据 ERROR 1071 (42000) at line 104: Specified key was too long; max key length is 1000 bytes 提示,查找 bbs.sql 文件相应行104行及后续10行:
sed -n '104,114p' bbs.sql
CREATE TABLE `pre_common_admincp_perm` (
`cpgroupid` smallint(6) unsigned NOT NULL,
`perm` varchar(255) NOT NULL,
UNIQUE KEY `cpgroupperm` (`cpgroupid`,`perm`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `pre_common_admincp_perm`
--