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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.
