MySQL
Text Data Types
Storage Sizes
Database Management
SQL Limits
MySQL TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT maximum sizes
Codemia Knowledge Hub ·
MySQL's four TEXT types store variable-length text up to these maximums: TINYTEXT 255 bytes, TEXT 65,535 bytes (64 KB), MEDIUMTEXT 16,777,215 bytes (16 MB) and LONGTEXT 4,294,967,295 bytes (4 GB). The limits are in bytes, so with a multi-byte character set such as utf8mb4 the number of characters you can store is lower.
| Text Type | Maximum Characters (single-byte charset) | Maximum Bytes | Storage Notes |
TINYTEXT | 255 | 255 | 1 byte for prefix. |
TEXT | 65,535 | 65,535 | 2 bytes for prefix. |
MEDIUMTEXT | 16,777,215 | 16,777,215 | 3 bytes for prefix. |
LONGTEXT | 4,294,967,295 | 4,294,967,295 | 4 bytes for prefix. |
Each type in detail
TINYTEXT
- Maximum size: 255 bytes, the smallest of the four. That is 255 characters only when every character is one byte.
- Overhead: One extra byte stores the length prefix.
- Use case: Short descriptions or notes.
TEXT
- Maximum size: 65,535 bytes (64 KB).
- Overhead: Two bytes for the length prefix.
- Use case: Medium-length text such as blog post excerpts, user comments or short articles.
MEDIUMTEXT
- Maximum size: 16,777,215 bytes (16 MB).
- Overhead: Three bytes for the length prefix.
- Use case: Larger text such as long blog articles, document content or large JSON strings.
LONGTEXT
- Maximum size: 4,294,967,295 bytes (4 GB), the largest of the four.
- Overhead: Four bytes for the length prefix.
- Use case: Very large data such as long user-submitted text, entire books or massive logs.
How character encoding reduces the character limit
The default character set is often utf8 or utf8mb4, where one character can take more than one byte:
utf8: Each character can use up to 3 bytes.utf8mb4: Each character can use up to 4 bytes.
If your data includes multi-byte characters, you can store fewer characters than the byte maximum.
Performance and indexing
- Resource use: Larger types such as
LONGTEXToffer plenty of space but can use more memory and processing power, which affects database performance. - Indexing: MySQL cannot index the full length of large text columns. You have to specify a prefix length for the index.
Related reading
- To what level does MongoDB lock on writes? or what does it mean by per connection
- Tool to create mongodb sharded cluster
- transaction rollback for multiple databases
- Transaction synchronization in Spring Boot
- Transactional annotation not working in Spring Boot
- Transactional annotation works with saveAndFlush?
- transactional replication using script
- TransactionManagementError You can''t execute queries until the end of the ''atomic'' block while using signals, but only during Unit Testing
System design interview problems on this topic
- Design a Distributed OLTP Database: solution and walkthrough
- Design a Wide Column Database: solution and walkthrough
- Design a Key Value Store: solution and walkthrough
- Design a Web Cache: solution and walkthrough

Course
Beginner
27 lessons
10 hours
System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.