MySQL 8.0 Reference Manual Including MySQL NDB Cluster 8.0 The format_bytes() Function


As of MySQL 8.0.16, format_bytes() is deprecated and will be removed in a future MySQL version. Applications that use it should be migrated to use the built-in FORMAT_BYTES() function instead. See Section 12.22, “Performance Schema Functions”

Given a byte count, converts it to human-readable format and returns a string consisting of a value and a units indicator. Depending on the size of the value, the units part is bytes, KiB (kibibytes), MiB (mebibytes), GiB (gibibytes), TiB (tebibytes), or PiB (pebibytes).

  • bytes TEXT: The byte count to format.

Return Value

A TEXT value.

mysql> SELECT sys.format_bytes(512), sys.format_bytes(18446644073709551615);
| sys.format_bytes(512) | sys.format_bytes(18446644073709551615) |
| 512 bytes             | 16383.91 PiB                           |