mysql5.7 在執行建立表或者增長字段時,發現row size長度過長,致使出現如下錯誤。html
[Err] 1118 - Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.
row size 其實就是全部字段的長度的總和。在不進行拆表的前提下解決(咱們不討論是否設計的合理性): 知識貼: https://dev.mysql.com/doc/refman/8.0/en/column-count-limit.htmlmysql
You may want to take a look at this article which explains a lot about MySQL row sizes. It's important to note that even if you use TEXT or BLOB fields, your row size could still be over 8K (limit for InnoDB) because it stores the first 768 bytes for each field inline in the page. The simplest way to fix this is to use the Barracuda file format with InnoDB. This basically gets rid of the problem altogether by only storing the 20 byte pointer to the text data instead of storing the first 768 bytes.
方法一:改變一些字段varchar爲TEXT or BLOB。 無效,不能解決問題。sql
最終解決方案this
查詢系統參數:code
show variables like '%innodb_strict_mode%'; show variables like '%innodb_log_file_size%';
修改前:orm
innodb_strict_mode ON innodb_log_file_size 536870912
修改mysql的配置文件, vi /etc/my.cnfhtm
innodb_log_file_size=1024M innodb_strict_mode=0
innodb_strict_mode=0 這個必定不能漏,不然不能生效。 重啓後:get
innodb_strict_mode OFF innodb_log_file_size 1073741824
it work 。 卡了好久,最終靠這個方案解決了。it