MySQL插入單行數據較大時報Row size too large錯誤 解決方案


mysql 版本 5.5

向目的MySQL寫入數據時,單行數據較大,遇到插入失敗,報錯信息如下:
Error 'Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.' on query. ......

 

 

解決:

1. 先查看

show GLOBAL VARIABLES LIKE '%file_format%';  
+--------------------------+----------+ | Variable_name | Value | +--------------------------+----------+ | innodb_file_format | Antelope | | innodb_file_format_check | ON | | innodb_file_format_max | Antelope | +--------------------------+----------+

mysql> show variables like '%per_table%'; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | innodb_file_per_table | OFF | +-----------------------+-------+ 1 row in set (0.03 sec)


2. 修改參數: my.cf中在[mysqld] 加入

innodb_file_format = Barracuda innodb_file_per_table = 1 

    檢查修改后的結果:

mysql> show variables like '%per_table%'; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | innodb_file_per_table | ON | +-----------------------+-------+ 1 row in set (0.00 sec) mysql> show GLOBAL VARIABLES LIKE '%file_format%'; +--------------------------+-----------+ | Variable_name | Value | +--------------------------+-----------+ | innodb_file_format | Barracuda | | innodb_file_format_check | ON | | innodb_file_format_max | Barracuda | +--------------------------+-----------+ 3 rows in set (0.00 sec)

3. 修改表

Alter table <table_name> engine=innodb ROW_FORMAT=DYNAMIC;



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM