> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/random_bytes.md).

# RANDOM\_BYTES

{% hint style="info" %}
`RANDOM_BYTES` is available from MariaDB [10.10.0](/docs/release-notes/community-server/old-releases/10.10/10.10.0.md).
{% endhint %}

The `RANDOM_BYTES` function generates a binary string of random bytes.

## Syntax

```bnf
RANDOM_BYTES(length)
```

## Description

Given a *length* from 1 to 1024, generates a binary string of *length* consisting of random bytes generated by the SSL library's random number generator.

See the `RAND_bytes()` function documentation of your SSL library for information on the random number generator. In the case of [OpenSSL](https://www.openssl.org/docs/man1.1.1/man3/RAND_bytes.html), a cryptographically secure pseudo random generator (CSPRNG) is used.

Statements containing the RANDOM\_BYTES function are [unsafe for statement-based replication](/docs/server/ha-and-performance/standard-replication/unsafe-statements-for-statement-based-replication.md).

An error occurs if *length* is outside the range 1 to 1024.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
