# RANDOM\_BYTES

{% hint style="info" %}
`RANDOM_BYTES` is available from MariaDB [10.10.0](https://app.gitbook.com/s/aEnK0ZXmUbJzqQrTjFyb/community-server/old-releases/10.10/10.10.0).
{% endhint %}

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

## Syntax

```sql
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](https://mariadb.com/docs/server/ha-and-performance/standard-replication/unsafe-statements-for-statement-based-replication).

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" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/random_bytes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
