[问题已处理]-mysql5.7 报错Unknown collation ‘utf8mb4_0900_ai_ci‘

golang 学习中 遇到报错的sql语句如下

DROP TABLE IF EXISTS `lesson`;
CREATE TABLE `lesson`  (
  `id` int(0) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

执行报错如下

[问题已处理]-mysql5.7 报错Unknown collation ‘utf8mb4_0900_ai_ci‘_第1张图片

将sql中的所有utf8mb4_0900_ai_ci替换为utf8_general_ci;utf8mb4替换为utf8

 sed -i 's/utf8mb4_0900_ai_ci/utf8_general_ci/g' itying.sql
 sed -i 's/utf8mb4/utf8/g' itying.sql

原因是 教程中数据库版本为8.0,我服务器上的mysql版本为5.7.12,因为是高版本导入到低版本有问题

DROP TABLE IF EXISTS `lesson`;
CREATE TABLE `lesson`  (
  `id` int(0) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

[问题已处理]-mysql5.7 报错Unknown collation ‘utf8mb4_0900_ai_ci‘_第2张图片

你可能感兴趣的:(mysql,问题已处理)