描述在本地測試代碼沒問題,但是部署到伺服器上時就報錯。錯誤> cross-env WEBPACK_TARGET=node NODE_ENV=production node ./server/app.jstruethe server is start at port 3333/usr/share/ng... ...
描述
在本地測試代碼沒問題,但是部署到伺服器上時就報錯。錯誤
> cross-env WEBPACK_TARGET=node NODE_ENV=production node ./server/app.js
true
the server is start at port 3333
/usr/share/nginx/nav/server/node_modules/koa-mysql-session/node_modules/co/index.js:292
throw err;
^
Error: ER_INDEX_COLUMN_TOO_LONG: Index column size too large. The maximum column size is 767 bytes.
原因:因為mysql的版本差異導致的,本地5.7,伺服器上5.6。koa-mysql-session是4年前的包不建議使用。
單列索引的長度的限制:5.6裡面預設不能超過767bytes,5.7不超過3072bytes
解決:
手動創建mysql_session_storeCREATE TABLE `_mysql_session_store` ( `id` varchar(255) NOT NULL,
`expires` bigint(20) DEFAULT NULL,
`data` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;參考: MySQL中索引的長度的限制
推薦: