使用 utf8mb4 代替 utf8

This commit is contained in:
Lmath 2020-06-14 08:49:29 +08:00
parent 7d5f9e8f37
commit ba8d777313
3 changed files with 41 additions and 25 deletions

18
.env
View File

@ -1 +1,17 @@
APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = test USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 DEBUG = true [LANG] default_lang = zh-cn
APP_DEBUG = true
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8mb4
DEBUG = true
[LANG]
default_lang = zh-cn

View File

@ -83,13 +83,13 @@ class Install extends BaseController
return json(['code'=>0,'msg'=>'数据库链接失败:'.$error]);die;
}
// 设置字符集
$link->query("SET NAMES 'utf8'");
$link->query("SET NAMES 'utf8mb4'");
if($link->server_info < 5.0){
return json(['code'=>0,'msg'=>'请将您的mysql升级到5.0以上']);die;
}
// 创建数据库并选中
if(!$link->select_db($data['DB_NAME'])){
$create_sql='CREATE DATABASE IF NOT EXISTS '.$data['DB_NAME'].' DEFAULT CHARACTER SET utf8;';
$create_sql='CREATE DATABASE IF NOT EXISTS '.$data['DB_NAME'].' DEFAULT CHARACTER SET utf8mb4;';
if(!$link->query($create_sql)){
return json(['code'=>0,'msg'=>'数据库连接失败']);die;
}

View File

@ -35,7 +35,7 @@ CREATE TABLE `vae_admin` (
`groups` varchar(255) NOT NULL DEFAULT '' COMMENT '权限组,隔开',
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`id`,`username`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理员';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员';
-- ----------------------------
-- Records of vae_admin
@ -49,13 +49,13 @@ CREATE TABLE `vae_admin_group` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '',
`status` int(1) NOT NULL DEFAULT '1',
`rules` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '用户组拥有的规则id 多个规则","隔开',
`rules` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '用户组拥有的规则id 多个规则","隔开',
`desc` text COMMENT '备注',
`create_time` int(11) NOT NULL DEFAULT '0',
`update_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限分组';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限分组';
-- ----------------------------
-- Records of vae_admin_group
@ -68,7 +68,7 @@ DROP TABLE IF EXISTS `vae_admin_rule`;
CREATE TABLE `vae_admin_rule` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(11) unsigned NOT NULL DEFAULT '0',
`src` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '规则',
`src` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '规则',
`title` varchar(255) NOT NULL DEFAULT '',
`is_menu` int(1) NOT NULL DEFAULT '1' COMMENT '1是菜单2不是',
`font_family` varchar(50) DEFAULT '' COMMENT '图标来源',
@ -78,7 +78,7 @@ CREATE TABLE `vae_admin_rule` (
`update_time` int(11) NOT NULL COMMENT '0',
PRIMARY KEY (`id`),
KEY `name` (`src`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8 COMMENT='权限节点';
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 COMMENT='权限节点';
-- ----------------------------
-- Records of vae_admin_rule
@ -143,7 +143,7 @@ DROP TABLE IF EXISTS `vae_cate`;
CREATE TABLE `vae_cate` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(50) NOT NULL,
`icon` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`pid` int(11) NOT NULL DEFAULT '0',
`status` int(1) NOT NULL DEFAULT '1' COMMENT '1正常0下架',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序,值越大越靠前',
@ -151,7 +151,7 @@ CREATE TABLE `vae_cate` (
`create_time` int(11) NOT NULL DEFAULT '0',
`update_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分类';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分类';
-- ----------------------------
-- Records of vae_cate
@ -163,11 +163,11 @@ CREATE TABLE `vae_cate` (
DROP TABLE IF EXISTS `vae_cate_group`;
CREATE TABLE `vae_cate_group` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`key` varchar(50) NOT NULL,
`desc` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分类分组';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分类分组';
-- ----------------------------
-- Records of vae_cate_group
@ -179,9 +179,9 @@ CREATE TABLE `vae_cate_group` (
DROP TABLE IF EXISTS `vae_content`;
CREATE TABLE `vae_content` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`img` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '图片,多图用,隔开',
`img` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '图片,多图用,隔开',
`status` int(1) NOT NULL DEFAULT '1' COMMENT '1正常0下架',
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`desc` varchar(500) DEFAULT NULL COMMENT '概要',
`content` text COMMENT '详情',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序,值越大越靠前',
@ -190,7 +190,7 @@ CREATE TABLE `vae_content` (
`create_time` int(11) NOT NULL DEFAULT '0',
`update_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='内容';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='内容';
-- ----------------------------
-- Records of vae_content
@ -202,12 +202,12 @@ CREATE TABLE `vae_content` (
DROP TABLE IF EXISTS `vae_content_group`;
CREATE TABLE `vae_content_group` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`key` varchar(50) NOT NULL,
`cate_group_id` int(11) NOT NULL DEFAULT '0' COMMENT '分类组id',
`desc` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='内容分组';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='内容分组';
-- ----------------------------
-- Records of vae_content_group
@ -221,14 +221,14 @@ CREATE TABLE `vae_nav` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(50) NOT NULL,
`icon` varchar(255) NOT NULL,
`src` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`src` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`status` int(1) NOT NULL DEFAULT '1' COMMENT '1正常0下架',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序,值越大越靠前',
`nav_group_id` int(11) NOT NULL DEFAULT '0',
`create_time` int(11) NOT NULL DEFAULT '0',
`update_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='导航';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='导航';
-- ----------------------------
-- Records of vae_nav
@ -240,11 +240,11 @@ CREATE TABLE `vae_nav` (
DROP TABLE IF EXISTS `vae_nav_group`;
CREATE TABLE `vae_nav_group` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`key` varchar(50) NOT NULL,
`desc` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='导航分组';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='导航分组';
-- ----------------------------
-- Records of vae_nav_group
@ -263,7 +263,7 @@ CREATE TABLE `vae_route` (
`create_time` int(11) NOT NULL DEFAULT '0',
`update_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='路由设置';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='路由设置';
-- ----------------------------
-- Records of vae_route
@ -283,7 +283,7 @@ CREATE TABLE `vae_slide` (
`create_time` int(11) NOT NULL DEFAULT '0',
`update_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='轮播';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='轮播';
-- ----------------------------
-- Records of vae_slide
@ -295,11 +295,11 @@ CREATE TABLE `vae_slide` (
DROP TABLE IF EXISTS `vae_slide_group`;
CREATE TABLE `vae_slide_group` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`key` varchar(50) NOT NULL,
`desc` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='轮播分组';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='轮播分组';
-- ----------------------------
-- Records of vae_slide_group