mysql5 7資料庫建表時異常提示

2021-10-10 06:05:41 字數 1188 閱讀 5649

今天在mysql建立表時出現 index column size too large. the maximum column size is 767 bytes.

建表的sql:

create table `t_sys_user_token` (

`token` varchar(500) not null comment 'token',

`expire_time` datetime default null comment '過期時間',

`update_time` datetime default null comment '更新時間',

primary key (`user_id`),

unique key `token` (`token`) using btree

) engine=innodb default charset=utf8 comment='系統使用者token';

原因是token這個索引列太大了,超出了mysql的預設索引大小767 bytes,網上搜尋說是

對資料庫進行設定

set global innodb_file_format = barracuda

set global innodb_large_prefix = on

按部就班試了下,果不其然失敗了,後通過分析mysql配置

在建表時新增 row_format=dynamic,如果有小夥伴項具體了解,那就自己慢慢查一查各引數的含義吧,下面是建表修改後的示例

create table `t_sys_user_token` (

`token` varchar(500) not null comment 'token',

`expire_time` datetime default null comment '過期時間',

`update_time` datetime default null comment '更新時間',

primary key (`user_id`),

unique key `token` (`token`) using btree

) engine=innodb default charset=utf8 row_format=dynamic comment='系統使用者token';

成功了;

MySQL 5 7 資料庫 跨伺服器跨資料庫建表

首先看看資料庫的有沒有federated這個引擎 再看support是不是yes 如果是no但是有federated引擎 1.開啟my.cnf 在mysqld下加入federated 2.重啟mysqld伺服器 3.建表語句 create table table 一堆屬性.primary key a...

Mysql5 7資料庫介紹

1 預設資料庫介紹 information schema 這個資料庫儲存了mysql伺服器所有資料庫的資訊。如資料庫名 資料庫的表 表欄的資料型別訪問許可權等。mysql 這個庫是系統庫,裡面儲存有賬戶資訊,許可權資訊等。performance schema 這是乙個mysql5.5開始新增的資料庫...

Centos 更改MySQL5 7資料庫目錄位置

centos7.3 安裝mysql5.7並修改初始密碼 基於 centos mysql 安裝與主從同步配置詳解 centos 通過yum安裝 rpm分發進行安裝 mysql的幾個人預設目錄如下 目錄目錄內容 usr bin 客戶端程式和指令碼 usr sbin mysqld伺服器 var lib m...