yii2-cms icon indicating copy to clipboard operation
yii2-cms copied to clipboard

初始化的数据库类型为utf8mb4 时会报错

Open kingwon opened this issue 7 years ago • 2 comments

m130524_201442_init 里面如果设置数据库为$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ENGINE=InnoDB'; 会报下面的错误;

Apply the above migrations? (yes|no) [no]:yes *** applying m130524_201442_init

create table {{%user}} ...Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes The SQL being executed was: CREATE TABLE user ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, username varchar(255) NOT NULL UNIQUE, auth_key varchar(32) NOT NULL, password_hash varchar(255) NOT NULL, password_reset_token varchar(255) UNIQUE, email varchar(255) NOT NULL UNIQUE, status smallint(6) NOT NULL DEFAULT 10, created_at int(11) NOT NULL, updated_at int(11) NOT NULL ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ENGINE=InnoDB'

in E:\Code\richin-cms\vendor\yiisoft\yii2\db\Schema.php:664

Error Info: Array ( [0] => 42000 [1] => 1071 [2] => Specified key was too long; max key length is 767 bytes )

kingwon avatar Sep 25 '18 15:09 kingwon

请问 MySQL 版本是哪个?

cuileon avatar Sep 26 '18 03:09 cuileon

请问 MySQL 版本是哪个?

5.5.53

kingwon avatar Sep 26 '18 03:09 kingwon