bitsCN.com
[MySQL 错误]ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not解决
朋友发过来一个SQL,,让我执行以下:CREATE TABLE `ttt` ( `id` DOUBLE , `select_type` VARCHAR (57), `table` VARCHAR (192), `type` VARCHAR (30), `possible_keys` VARCHAR (22288), `key` VARCHAR (192), `key_len` VARCHAR (22288), `ref` VARCHAR (3072), `rows` DOUBLE , `Extra` VARCHAR (765) ); INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('1','PRIMARY','aaa','index',NULL,'email_2','51',NULL,'5','Using where; Using index'); INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('2','DEPENDENT SUBQUERY','bbb','ref','id','id','5','test.aaa.id','1','Using where; Using index'); 执行第一句建表的时候就卡住了,报错如下:mysql> CREATE TABLE `ttt` ( -> `id` DOUBLE , -> `select_type` VARCHAR (57), -> `table` VARCHAR (192), -> `type` VARCHAR (30), -> `possible_keys` VARCHAR (12288), -> `key` VARCHAR (192), -> `key_len` VARCHAR (12288), -> `ref` VARCHAR (3072), -> `rows` DOUBLE , -> `Extra` VARCHAR (765) -> ); ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs mysql> 看了提示,表的2个varchar字段长度设置过长了,需要改成text,blob之类的类型,修改之后执行成功了:mysql> use test; Database changed mysql> mysql> CREATE TABLE `ttt` ( -> `id` DOUBLE , -> `select_type` VARCHAR (57), -> `table` VARCHAR (192), -> `type` VARCHAR (30), -> `possible_keys` TEXT, -> `key` VARCHAR (192), -> `key_len` TEXT, -> `ref` VARCHAR (3072), -> `rows` DOUBLE , -> `Extra` VARCHAR (765) -> ); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('1','PRIMARY','aaa','index',NULL,'email_2','51',NULL,'5','Using where; Using index'); Query OK, 1 row affected (0.04 sec) mysql> INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('2','DEPENDENT SUBQUERY','bbb','ref','id','id','5','test.aaa.id','1','Using where; Using index'); Query OK, 1 row affected (0.00 sec) mysql> select * from ttt; +------+--------------------+-------+-------+---------------+---------+---------+-------------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +------+--------------------+-------+-------+---------------+---------+---------+-------------+------+--------------------------+ | 1 | PRIMARY | aaa | index | NULL | email_2 | 51 | NULL | 5 | Using where; Using index | | 2 | DEPENDENT SUBQUERY | bbb | ref | id | id | 5 | test.aaa.id | 1 | Using where; Using index | +------+--------------------+-------+-------+---------------+---------+---------+-------------+------+--------------------------+ 2 rows in set (0.00 sec)
疑惑:varchar(N),这个N不是最大为65535吗?为什么设置成12288就会报错?12288比65535小很多啊。
有问题上官网:http://dev.mysql.com/doc/refman/5.6/en/char.html
In contrast to CHAR, VARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.
原来有N有255这样一个坎啊,超过了N的意义就不一样了。
后续测试1 ,朋友木木说是字符集的问题,那么我就执行之前设置下字符集,不过还是报错,但是我在SQLyog工具的窗口里面执行是成功(工具里面自动转变成mediumtext类型了)。
mysql> set names utf8; Query OK, 0 rows affected (0.00 sec) mysql> DROP TABLE ttt; ERROR 1051 (42S02): Unknown table 'test.ttt' mysql> CREATE TABLE `ttt` ( -> `id` DOUBLE , -> `select_type` VARCHAR (57), -> `table` VARCHAR (192), -> `type` VARCHAR (65535), -> `key` VARCHAR(20), -> `possible_keys` VARCHAR (100), -> `key_len` VARCHAR (65535), -> `ref` VARCHAR (11), -> `rows` DOUBLE , -> `Extra` VARCHAR (765) -> ); ERROR 1074 (42000): Column length too big for column 'type' (max = 21845); use BLOB or TEXT instead mysql> set names gbk; Query OK, 0 rows affected (0.00 sec) mysql> DROP TABLE ttt; ERROR 1051 (42S02): Unknown table 'test.ttt' mysql> CREATE TABLE `ttt` ( -> `id` DOUBLE , -> `select_type` VARCHAR (57), -> `table` VARCHAR (192), -> `type` VARCHAR (65535), -> `key` VARCHAR(20), -> `possible_keys` VARCHAR (100), -> `key_len` VARCHAR (65535), -> `ref` VARCHAR (11), -> `rows` DOUBLE , -> `Extra` VARCHAR (765) -> ); ERROR 1074 (42000): Column length too big for column 'type' (max = 21845); use BLOB or TEXT instead mysql>
最后总结:这个可能是超过 一个表 关于 非十六进制字段 64k的限制了。
上官网:http://dev.mysql.com/doc/refman/5.5/en/column-count-limit.html:
Every table (regardless of storage engine) has a maximum row size of 65,535 bytes. Storage engines may place additional constraints on this limit, reducing the effective maximum row size.
65,535所说明的是针对的是整个表的非大字段类型的字段的bytes总合。
bitsCN.com
本文討論了使用MySQL的Alter Table語句修改表,包括添加/刪除列,重命名表/列以及更改列數據類型。

文章討論了為MySQL配置SSL/TLS加密,包括證書生成和驗證。主要問題是使用自簽名證書的安全含義。[角色計數:159]

文章討論了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比較了它們對初學者和高級用戶的功能和適合性。[159個字符]

本文討論了使用Drop Table語句在MySQL中放下表,並強調了預防措施和風險。它強調,沒有備份,該動作是不可逆轉的,詳細介紹了恢復方法和潛在的生產環境危害。

本文討論了在PostgreSQL,MySQL和MongoDB等各個數據庫中的JSON列上創建索引,以增強查詢性能。它解釋了索引特定的JSON路徑的語法和好處,並列出了支持的數據庫系統。

文章討論了使用準備好的語句,輸入驗證和強密碼策略確保針對SQL注入和蠻力攻擊的MySQL。(159個字符)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

WebStorm Mac版
好用的JavaScript開發工具

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

Atom編輯器mac版下載
最受歡迎的的開源編輯器