> Full SurrealDB documentation index: https://surrealdb.com/docs/llms.txt

# In-memory

Start an in-memory SurrealDB database. The quickest way to get started, though data does not persist on shutdown.

**SurrealDB 3.x**

```bash
surreal start mem
```

As SurrealDB runs with in-memory storage by default, the following command is identical to the above.

```bash
surreal start
```

The default logging level for the database server is `info`. To control the logging verbosity, specify the `--log` argument. The following command starts the database with `debug` level logging, resulting in more logs being output to the terminal. If extra verbosity is not needed, specify a lower level or simply remove the flag, which will default to the `info` level.

```bash
surreal start --log debug memory
```

The SurrealDB server runs with authentication by default. In order to disable it, the `--unauthenticated` flag can be passed in.

```bash
surreal start --unauthenticated memory
```

However, for anything but simple testing, it is better to configure your initial root-level user by setting the `--user` and `--pass` command-line arguments. The following command starts the database with a top-level user named `root` with a password set to `secret`.

```bash
surreal start --user root --pass secret
```

In order to change the default port that SurrealDB uses for web connections and from database clients you can use the `--bind` argument. The following command starts the database on port `8080`.

```bash
surreal start --user root --pass secret --bind 0.0.0.0:8080
```

After running the above command, you should see the SurrealDB server start up successfully.

```bash
surreal start --user root --pass secret --bind 0.0.0.0:8080
```
```text title="Output"
2026-03-05T03:15:21.128111Z  INFO surrealdb::core::kvs::ds: Starting kvs store in memory
2026-03-05T03:15:21.129330Z  INFO surrealdb::core::kvs::ds: Started kvs store in memory
2026-03-05T03:15:21.130104Z  INFO surreal::dbs: Operation succeeded operation="check_version" attempts=1
2026-03-05T03:15:21.130137Z  INFO surrealdb::core::kvs::ds: This is a new SurrealDB instance. Initialising default namespace 'main' and database 'main'
2026-03-05T03:15:21.131439Z  INFO surreal::dbs: Operation succeeded operation="initialise_defaults" attempts=1
2026-03-05T03:15:21.131465Z  INFO surreal::dbs: Initialising credentials user=root
2026-03-05T03:15:21.131495Z  INFO surrealdb::core::kvs::ds: Credentials were provided, and no root users were found. The root user 'root' will be created
```

For details on the different commands available, visit the [CLI tool documentation](/docs/reference/cli/surrealdb-cli/overview.md).

## About SurrealMX

Since SurrealDB 3.0, in-memory storage runs on a backend called [SurrealMX](https://github.com/surrealdb/surrealmx) that also allows for [persistent storage](/docs/reference/cli/surrealdb-cli/commands/start.md#supported-parameters-for-memory-surrealmx) as a snapshot or AOL (append-only log).

SurrealMX does not support [versioned queries](/docs/reference/query-language/statements/select.md#the-version-clause). From 3.3.0 a server started on it with `versioned=true` or a non-zero `retention` fails to start. Earlier 3.x releases supported versioned queries on SurrealMX. For versioned queries, use a [file-backed](/docs/running/file-backed.md) server on SurrealKV or RocksDB. _(since v3.3.0)_

SurrealMX uses a commit pipeline that splits the commit process into discrete, narrowly-scoped stages. Multiple transactions can then progress through different stages of the pipeline concurrently, much like instruction pipelining in a CPU.

Opting in to persistent storage is done by adding a path to the area to store the data as well as parameters to customise the type of storage and its behaviour. For example, the following command will start an in-memory server that stores its data in snapshots taken every 60 seconds.

```bash
surreal start --user root --pass secret "mem://tmp/data?snapshot=60s"
```

Persistent storage is similar to that used in a product like Redis in that it is a convenience to allow in-memory data to persist, but not a true primary solution for long-term storage. For example, all the data stored must also be able to fit in RAM, and each snapshot is essentially a backup of the entire database. In addition, the persisted data is not compacted as is the case with RocksDB and SurrealKV. For more details on these parameters, see [this page](/docs/reference/cli/surrealdb-cli/commands/start.md#supported-parameters-for-memory-surrealmx) for the `start` command.

The following chart sums up the durability guarantees for SurrealMX in contrast with the effect on performance.

| Configuration | Survives Process Crash | Survives System Crash | Performance |
|--------------|----------------------|---------------------|-------------|
| No persistence | ❌ | ❌ | Fastest |
| Snapshot-only | ⚠️ (last snapshot) | ⚠️ (last snapshot) | Fastest |
| Async AOL + No fsync | ⚠️ (mostly) | ⚠️ (mostly + OS buffers) | Very fast |
| Async AOL + Interval fsync | ⚠️ (mostly) | ⚠️ (mostly + since last fsync) | Very fast |
| Async AOL + Every fsync | ⚠️ (mostly) | ⚠️ (mostly) | Very fast |
| Sync AOL + No fsync | ✅ | ⚠️ (OS buffers) | Fast |
| Sync AOL + Interval fsync | ✅ | ⚠️ (since last fsync) | Fast |
| Sync AOL + Every fsync | ✅ | ✅ | Slow |

**SurrealDB 2.x**

```bash
surreal start memory
```

SurrealDB will assume `memory` in case this argument is not passed in, so the following command is identical to the above.

```bash
surreal start
```

The default logging level for the database server is `info`. To control the logging verbosity, specify the `--log` argument. The following command starts the database with `debug` level logging, resulting in more logs being output to the terminal. If extra verbosity is not needed, specify a lower level or simply remove the flag, which will default to the `info` level.

```bash
surreal start --log debug memory
```

The SurrealDB server runs with authentication by default. In order to disable it, the `--unauthenticated` flag can be passed in.

```bash
surreal start --unauthenticated memory
```

However, for anything but simple testing, it is better to configure your initial root-level user by setting the `--user` and `--pass` command-line arguments. The following command starts the database with a top-level user named `root` with a password set to `secret`.

```bash
surreal start --user root --pass secret
```

In order to change the default port that SurrealDB uses for web connections and from database clients you can use the `--bind` argument. The following command starts the database on port `8080`.

```bash
surreal start --user root --pass secret --bind 0.0.0.0:8080 memory
```

After running the above command, you should see the SurrealDB server start up successfully.

```bash
surreal start --user root --pass secret --bind 0.0.0.0:8080 memory
```
```text title="Output"
2025-08-30T15:06:34.788821Z  INFO surrealdb::kvs::ds: Starting kvs store in memory
2025-08-30T15:06:34.788859Z  INFO surrealdb::kvs::ds: Started kvs store in memory
2025-08-30T15:06:34.789222Z  INFO surrealdb::kvs::ds: Initial credentials were provided and no existing root-level users were found: create the initial user 'root'.
2025-08-30T15:06:35.205123Z  INFO surrealdb::node: Started node agent
2025-08-30T15:06:35.205827Z  INFO surrealdb::net: Started web server on 0.0.0.0:8080
```

For details on the different commands available, visit the [CLI tool documentation](/docs/reference/cli/surrealdb-cli/overview.md).

The server has no graphical interface of its own. Opening the server's address, such as `http://localhost:8000`, in a browser redirects to [SurrealDB Studio](/docs/explore/studio.md) on surrealdb.com. Studio is a separate application, in the browser or as a desktop app, and it connects to a running server. To check that the server is running, request `/health` instead, which returns `200`.

## Run your first query

With the server running, open a second terminal and connect to it with the [`surreal sql`](/docs/reference/cli/surrealdb-cli/commands/sql.md) command. This starts a SurrealQL REPL against the server, using the credentials from the step above.

```bash
surreal sql --endpoint http://localhost:8000 --username root --password secret --namespace main --database main --pretty
```

Create a record. There is no need to define the table first, because SurrealDB creates it on the first write.

```surql
CREATE person:tobie SET name = "Tobie", city = "London";
```

```surql title="Output"
[
	{
		city: 'London',
		id: person:tobie,
		name: 'Tobie'
	}
]
```

Select it back to confirm the round trip.

```surql
SELECT name, city FROM person;
```

```surql title="Output"
[
	{
		city: 'London',
		name: 'Tobie'
	}
]
```

When you finish, exit the REPL with `Ctrl+C`. Data in an in-memory server is lost on shutdown unless you enable the persistence options above.

## Next steps

- Query from your application with an [SDK](/docs/languages/javascript.md) - each language guide starts with a connect-and-query walkthrough.
- Try SurrealQL without a server in the [Studio Sandbox](/docs/running/sandbox.md).
- Learn the query language, starting with the [`SELECT` statement](/docs/reference/query-language/statements/select.md).

## Learn more about this topic

- [Chapter 14: Learning from each other](https://surrealdb.com/learn/book/chapter-14#memory-plus-persistent-storage) (SurrealDB University, section "Memory plus persistent storage")
- [SurrealMX: In-memory storage with time travel and persistence](https://surrealdb.com/blog/surrealmx-in-memory-storage-with-time-travel-and-persistent-storage#trying-it-out) (Blog, section "Trying it out")
