# Creating a Trace File

{% hint style="info" %}
This page is focused on lower-level development: It contains technical "how-to" documentation for engineers who are actually modifying the MariaDB source code (e.g., compiling for debug, using GDB, and memory leak detection in the code).
{% endhint %}

If `mysqld` is crashing, creating a trace file is a good way to find the issue.

A `mysqld` binary that has been compiled with debugging support can create trace files using the DBUG package created by Fred Fish. To find out if your `mysqld` binary has debugging support, run `mysqld -V` on the command line. If the version number ends in `-debug` then your `mysqld` binary was compiled with debugging support.

See [Compiling MariaDB for debugging](/docs/server/reference/product-development/mariadb-fault-finding/compiling-mariadb-for-debugging.md) for instructions on how to create your own `mysqld` binary with debugging enabled.

To create the trace log, start `mysqld` like so:

```
mysqld --debug
```

Without options for --debug, the trace file will be named `/tmp/mysqld.trace` in MySQL and older versions of MariaDB before 10.5 and `/tmp/mariadbd.trace` starting from [MariaDB 10.5](/docs/release-notes/community-server/old-releases/10.5/what-is-mariadb-105.md).

On Windows, the debug `mysqld` is called `mysqld-debug` and you should also use the `--standalone` option. So the command on Windows will look like:

```
mysqld-debug --debug --standalone
```

Once the server is started, use the regular `mysql` command-line client (or another client) to connect and work with the server.

After you are finished debugging, stop the server with:

```
mysqladmin shutdown
```

## DBUG Options

Trace files can grow to a significant size. You can reduce their size by telling the server to only log certain items.

The `--debug` flag can take extra options in the form of a colon (:) delimited string of options. Individual options can have comma-separated sub-options.

For example:

```
mysqld --debug=d,info,error,query:o,/tmp/mariadbd.trace
```

The '`d`' option limits the output to the named DBUG\_ macros. In the above example, the `/tmp/mariadbd.trace` tracefile will contain output from the info, error, and query DBUG macros. A '`d`' by itself (with no sub-options) will select all DBUG\_ macros.

The '`o`' option redirects the output to a file (`/tmp/mariadbd.trace` in the example above) and overwrites the file if it exists.

## See Also

* [Options for --debug](/docs/connectors/mariadb-connector-c/api-functions/mysql_debug.md)

<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/product-development/mariadb-fault-finding/creating-a-trace-file.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.
