# Configuration

Memgraph has a set of configuration options that can be fine-tuned for specific needs. 

The main Memgraph configuration file is available at the
`/etc/memgraph/memgraph.conf`. The file contains a set of default configuration values 
and key-value pairs that can be modified to suit your specific needs.

Each configuration setting is in the form: `--setting-name=value`.

> **Warning**
>
> Boolean flags **must** use `=` syntax: `--flag=true` or `--flag=false`. Writing
> `--flag false` (space-separated) does **not** work as expected — it sets the flag
> to `true` and treats `false` as an unrecognized argument. You can also use
> `--flag` to enable or `--noflag` to disable.

You can check the current configuration by using the following query:

```opencypher
SHOW CONFIG;
```

## Changing configuration

The `memgraph.conf` file is the persistency for configuration. Changing the
configuration settings depends on the way you are using Memgraph and the
configuration settings you want to change.

Most of the configuration changes need to happen before Memgraph is
started. Still, a set of configuration settings can be [changed during
runtime](https://memgraph.com/docs/configuration/configuration-settings#change-configuration-settings-during-runtime). 

Changing the configuration settings for Memgraph differs if you are using
Memgraph with **Docker**, **Docker Compose**, or if it was installed on the
native **Linux**.

**Docker**

### Pass the configuration flags

        The most simple way to change the configuration with Docker is by passing 
        the configuration options within the `docker run` command.
        For example, if you want to limit memory usage for the whole instance to 
        50 MiB and set the log level to `TRACE`, pass the configuration argument 
        like this.

```
docker run -p 7687:7687 -p 7444:7444 memgraph/memgraph --memory-limit=50 --log-level=TRACE
```
        
        
### Update the configuration file

        Another way of updating the default configuration is by updating the 
        configuration file on the running instance, but such action requires 
        restart so the update is applied. Here are the steps to change the 
        default configuration file:

        

            
### Start Memgraph

            Start Memgraph with a `docker run` command.

            
### Find container ID

            Open a new terminal and find the `CONTAINER ID` of the Memgraph Docker container
            using the following command:

```
docker ps
```

            
### Enter the container

            Enter the Docker container with the following command:

```plaintext
docker exec -it -u 0 <CONTAINER ID> bash
```

            
### Install the text editor of your choice

            For example, if you want to use `vim` run:

```
apt-get update && apt-get install -y vim
```

            
### Edit the configuration file

            The file is located at `/etc/memgraph/memgraph.conf`.

            
### Restart the instance

            Run the following command:

```
docker restart <CONTAINER ID>
```

        

        
### Provide additional configuration file

        To achieve a different configuration on startup, you can also provide the 
        path to the additional configuration file which will override the default
        one. The file should contain the configuration settings in the form
        `--setting-name=value`. Still, if any configuration settings are set as 
        arguments, they will override the settings in the additional configuration 
        file as well. Providing the path to the additional configuration file 
        requires more steps than setting the configuration via arguments. That's 
        because the file you're pointing to must be located within the container 
        before the container is running. To provide the additional configuration 
        file, follow these steps:

        
            
### Create a container

            Create a Docker container with the `--flag-file` argument pointing to the location where you'll save the additional configuration file.
            The file must be saved within the container, ideally in the `/etc/memgraph` folder, where the default configuration file is stored.
```
docker create --name memgraph_container -p 7687:7687 -p 7444:7444 memgraph/memgraph --flag-file=/etc/memgraph/my.conf 
```

            Besides the `--flag-file` flag, you can [set the environment variable](#environment-variables) `MEMGRAPH_CONFIG` to achieve the same.

            
### Copy the additional configuration file

```
docker cp my.conf memgraph_container:/etc/memgraph/my.conf
```

            
### Start the container

```
docker start memgraph_container
```
        

**Docker Compose**

### Pass the configuration flags

        The most simple way to change the configuration with Docker Compose is 
        by passing the configuration options within the `command` line in the 
        `docker-compose.yml` file.

        For example, if you want to limit memory usage for the whole instance to 
        50 MiB and set the log level to `TRACE`, pass the configuration argument 
        like this.

```yaml
services:
  memgraph:
    image: "memgraph/memgraph"
    ports:
      - "7687:7687"
      - "7444:7444"
    volumes:
      - mg_lib:/var/lib/memgraph
      - mg_log:/var/log/memgraph
    command: ["--log-level=TRACE", "--memory-limit=50"]
volumes:
  mg_lib:
  mg_log:
  mg_etc:
```

        
### Update the configuration file

        Another way of updating the default configuration is by updating the 
        configuration file on the running instance, but such action requires 
        restart so the update is applied. Here are the steps to change the 
        default configuration file:

        
          
### Start Memgraph

          Start Memgraph with a `docker-compose up` command.

          
### Find container ID

          Open a new terminal and find the `CONTAINER ID` of the Memgraph Docker 
          container using the following command:

```
docker ps
```

          
### Enter the container

          Enter the Docker container with the following command:

```plaintext
docker exec -it -u 0 <CONTAINER ID> bash
```

          
### Install the text editor of your choice

          For example, if you want to use `vim` run:

```
apt-get update && apt-get install -y vim
```

          
### Edit the configuration file

          The file is located at `/etc/memgraph/memgraph.conf`.

          
### Restart the instance

          Once you've added the environment variables, restart the instance using 
          Docker Compose. Place yourself in the terminal in the folder containing 
          the docker-compose.yml file and run the following command:
```
docker-compose restart 
```

          This will restart the containers with the updated environment variables. 
        

        
### Provide additional configuration file

        To achieve a different configuration on startup, you can also provide the 
        path to the additional configuration file which will override the default
        one. The file should contain the configuration settings in the form
        `--setting-name=value`. Still, if any configuration settings are set as 
        arguments, they will override the settings in the additional configuration 
        file as well. Providing the path to the additional configuration file 
        requires more steps than setting the configuration via arguments. That's 
        because the file you're pointing to must be located within the container 
        before the container is running. To provide the additional configuration 
        file, follow these steps:

        
            
### Create a container

            In your Docker Compose file, Add the `--flag-file` argument pointing 
            to the location where you'll save the additional configuration file.
            The file must be saved within the container, ideally in the 
            `/etc/memgraph` folder, where the default configuration file is stored.
```
docker-compose -f docker-compose.yml create
```

            Besides the `--flag-file` flag, you can 
            [set the environment variable](#environment-variables) 
            `MEMGRAPH_CONFIG` to achieve the same.

            
### Find container ID

            Open a new terminal and find the `CONTAINER_ID` of the Memgraph Docker 
            container using the following command:

```
docker ps -a
```
            
            
### Copy the additional configuration file

```
docker cp my.conf <CONTAINER_ID>:/etc/memgraph/my.conf
```

            
### Start the container

```
docker-compose up
```
        

**Linux**

### Update the configuration file

        Once Memgraph is installed on your Linux machine, check the status with: 
``` bash
systemctl status memgraph
```
        
        If the instance is in a running state, stop the Memgraph instance by running the following command:
```bash
sudo systemctl stop memgraph
```
       The configuration file is available at `/etc/memgraph/memgraph.conf`. Open the configuration file with your favorite text editor.
        Modify it, save the changes, and start the instance by running the following command:

```bash
sudo systemctl start memgraph
```

        
### Provide additional configuration file

        To achieve a different configuration on startup, you can also provide the path
        to the additional configuration file which will override the default
        one. The file should contain the configuration settings in the form
        `--setting-name=value`. 
        To provide the path to the additional configuration file, [set the environment variable](#environment-variables) `MEMGRAPH_CONFIG` to the correct path.

---

### Change configuration during runtime

Memgraph contains settings that can be modified during runtime using a Cypher query.
Some runtime settings are persisted between multiple runs, while others will
fallback to the value of the command-line argument.

| Setting name               | Description                                                                                                                                                                                                                                                                           | Persistent between runs |
|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| organization.name          | Name of the organization using the instance of Memgraph (used for verifying the license key).                                                                                                                                                                                         | yes                     |
| enterprise.license         | License key for Memgraph Enterprise.                                                                                                                                                                                                                                                  | yes                     |
| server.name                | Bolt server name.                                                                                                                                                                                                                                                                     | yes                     |
| query.timeout              | Maximum allowed query execution time. Value of 0 means no limit.                                                                                                                                                                                                                      | yes                     |
| log.level                  | Minimum log level. Allowed values: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL.                                                                                                                                                                                                      | no                      |
| log.to_stderr              | Log messages go to `stderr` in addition to `logfiles`.                                                                                                                                                                                                                                | no                      |
| log.min_duration_ms        | Log successful queries whose `parse + plan + execute` time (ms) reaches this threshold with a `[slow-query]` tag. `-1` disables; `0` logs every successful query. See [Slow and failed query logging](https://memgraph.com/docs/database-management/logs#slow-and-failed-query-logging).                       | yes                     |
| log.failed_queries         | Log each failed query with a `[failed-query]` tag. See [Slow and failed query logging](https://memgraph.com/docs/database-management/logs#slow-and-failed-query-logging).                                                                                                                                       | yes                     |
| log.query_plan             | Append the query's EXPLAIN plan to its `[slow-query]` log line. See [Slow and failed query logging](https://memgraph.com/docs/database-management/logs#slow-and-failed-query-logging).                                                                                                                          | yes                     |
| cartesian-product-enabled  | Enforces cartesian product operator during query matching.                                                                                                                                                                                                                            | no                      |
| hops_limit_partial_results | If set to `true`, partial results are returned when the hops limit is reached. If set to `false`, an exception is thrown when the hops limit is reached. The default value is `true`.                                                                                                 | yes                     |
| timezone                   | IANA timezone identifier string setting the instance's timezone.                                                                                                                                                                                                                      | yes                     |
| storage.snapshot.interval  | Define periodic snapshot schedule via 6-field cron expression (seconds, minute, hour, day of month, month, day of week—an [Enterprise feature](https://memgraph.com/docs/database-management/enabling-memgraph-enterprise)) or as a period in seconds. Set to empty string to disable.                         | no                      |
| storage-gc-aggressive      | Enables aggressive garbage collection, which performs full cleanup on GC call where deltas, vertices, edges or indices and constraints skip lists are being cleaned up. This setting requires taking a unique lock that will temporarily block the system during garbage collection.  | yes                     |
| storage.access_timeout_sec | Storage access timeout in seconds. Guards against queries waiting indefinitely for storage access. Valid range: [1, 1000000]. Corresponds to `--storage-access-timeout-sec`.                                                                                                          | no                      |
| storage.omit_vector_index_properties_on_return | When `true`, properties backed by a vector index (for example embeddings) are omitted when a whole node or relationship is returned; they remain accessible via explicit property access (`n.embedding`, `properties(n)`). Corresponds to `--storage-omit-vector-index-properties-on-return`. | yes |
| aws.region                 | AWS region in which your S3 service is located.                                                                                                                                                                                                                                       | yes                     |
| aws.access_key             | Access key used to READ the file from S3.                                                                                                                                                                                                                                             | yes                     |
| aws.secret_key             | Secret key used to READ the file from S3.                                                                                                                                                                                                                                             | yes                     |
| aws.endpoint_url           | URL on which S3 can be accessed (if using some other S3-compatible storage).                                                                                                                                                                                                          | yes                     |

All settings can be fetched by calling the following query:

```opencypher
SHOW DATABASE SETTINGS;
```

To check the value of a single setting, you can use a slightly different query:

```opencypher
SHOW DATABASE SETTING "setting.name";
```

If you want to change a value for a specific setting, following query should be used:

```opencypher
SET DATABASE SETTING "setting.name" TO "some-value";
```

A small set of settings can also be overridden for the current session only,
taking precedence over the global value, using `SET SESSION SETTING` and
`RESET SESSION SETTING`. The session-overridable settings are `log.min_duration_ms`,
`log.failed_queries` and `log.query_plan`; see [Slow and failed query
logging](https://memgraph.com/docs/database-management/logs#configuring-at-runtime-and-per-session).

For reusable query values accessed as `$name`, see
[Server-side parameters](https://memgraph.com/docs/database-management/server-side-parameters). Unlike
database settings, server-side parameters are resolved during query execution.

### Multitenancy and configuration 

If you are using a multi-tenant architecture, all isolated databases share
identical configurations. At the moment, there is no way to specify a
per-database configuration.

## List of configuration flags

### Audit log

This section contains the list of flags that are used to configure the audit
logging.

| Flag                             | Description                                                                                    |
|----------------------------------|------------------------------------------------------------------------------------------------|
| `--audit-enabled`                  | Enables audit logging.                                                                         |
| `--audit-buffer-size`              | Controls the in-memory buffer size used for audit logs.                                        |
| `--audit-buffer-flush-interval-ms` | Controls the time interval (in milliseconds) used for flushing the in-memory buffer to disk.   |

### Auth module

This section contains the list of flags that are used to configure the external
auth module authentication and authorization mechanisms used by Memgraph.

| Flag                             | Description
| ---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--auth-module-mappings`           | Associates auth schemes to external modules. A mapping is structured as follows: `<scheme>:<absolute path to module>` and individual entries are separated with `;`. SSO schemes with default module paths can omit the path. If the mapping contains whitespace, enclose the flag value with quotation marks. |
| `--auth-module-timeout-ms`         | Specifies the maximum time that Memgraph will wait for a response from the external auth module.                                                                                                                                                                                  |
| `--auth-password-permit-null`      | Can be set to false to disable null passwords.                                                                                                                                                                                                                                    |
| `--auth-password-strength-regex`   | The regular expression that should be used to match the entire entered password to ensure its strength. The syntax for regular expressions is derived from a [modified version of the ECMAScript regular expression grammar](https://en.cppreference.com/w/cpp/regex/ecmascript). |
| `--auth-user-or-role-regex`        | Set to the regular expression that each user or role name must fulfill. The syntax for regular expressions is derived from a [modified version of the ECMAScript regular expression grammar](https://en.cppreference.com/w/cpp/regex/ecmascript).                                 |

### Bolt

This section contains the list of flags that are used to configure the Bolt
protocol used by Memgraph.

| Flag                                                                                  | Description                                                                                                                       | Type       |
|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|------------|
| `--bolt-address=0.0.0.0`                                                               | IP address on which the Bolt server should listen.                                                                                | `[string]` |
| `--bolt-cert-file`                                                                     | Certificate file which should be used for the Bolt server.                                                                        | `[string]` |
| `--bolt-key-file`                                                                      | Key file which should be used for the Bolt server.                                                                                | `[string]` |
| `--bolt-num-workers`                                                                   | Number of workers used by the Bolt server. 
By default, this will be the number of processing units available on the machine. | `[int32]`  |
| `--bolt-port=7687`                                                                      | Port on which the Bolt server should listen.                                                                                      | `[int32]`  |
| `--bolt-server-name-for-init=Neo4j/v5.11.0 compatible graph database server - Memgraph` | Server name which the database should send to the client in the Bolt INIT message.                                                | `[string]` |

> **Info**
>
> Memgraph does not limit the maximum amount of simultaneous sessions.
> Transactions within all open sessions are served with a limited number of Bolt
> workers simultaneously.

### High availability

This section contains the list of flags that are used to configure highly available cluster in Memgraph.

| Flag                                     | Description                                                                                                                                                  | Type       |
|------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
| `--coordinator-id`                         | Raft server id on coordinator instance.                                                                                                                      | `[int32]` |
| `--coordinator-port`                       | Raft server's port on coordinator instance.                                                                                                                  | `[uint32]` |
| `--management-port`                        | Port on which replication instances receive messages from coordinator .                                                                                      | `[uint32]` |
| `--nuraft-log-file`                        | Path to the file where NuRaft logs are saved.                                                                                                                | `[string]` |
| `--coordinator-hostname`                   | Coordinator's instance hostname. Used only in `SHOW INSTANCES` query.                                                                                        | `[string]` |
| `--cluster-cert-file`                      | Certificate file used for [intra-cluster TLS](https://memgraph.com/docs/clustering/high-availability/how-high-availability-works#intra-cluster-tls) communication. Must be set together with `--cluster-key-file` and `--cluster-ca-file`.                                                                                | `[string]` |
| `--cluster-key-file`                       | Key file used for [intra-cluster TLS](https://memgraph.com/docs/clustering/high-availability/how-high-availability-works#intra-cluster-tls) communication. Must be set together with `--cluster-cert-file` and `--cluster-ca-file`.                                                                                      | `[string]` |
| `--cluster-ca-file`                        | File storing the certificate of the Certificate Authority you trust for [intra-cluster TLS](https://memgraph.com/docs/clustering/high-availability/how-high-availability-works#intra-cluster-tls) communication. Must be set together with `--cluster-cert-file` and `--cluster-key-file`.                               | `[string]` |

### Query

This section contains the list of flags that are used to configure query
execution in Memgraph.

| Flag                                                                          | Description                                                                                                                                                                                                      | Type       |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
| `--cartesian-product-enabled=true`                                              | Enforces whether cartesian product matching is going to be used in the plans.                                                                                                                                    | `[bool]`   |
| `--query-ast-cache-max-size=1000`                                               | Maximum number of parsed query abstract syntax trees to cache. 
Value of 0 disables the cache.                                                                                                                 | `[int32]`  |
| `--query-callable-mappings-path=/etc/memgraph/apoc_compatibility_mappings.json` | Path to the JSON file that contains possible alias mappings for query procedures in the form of key-value pairs.                                                                                                 | `[string]` |
| `--query-cost-planner=true`                                                     | Use the cost-estimating query planner. When enabled (`true`), Memgraph generates multiple query plans, selecting the one with the lowest cost. If disabled (`false`), it creates a single plan that is executed. | `[bool]`   |
| `--query-execution-timeout-sec=600`                                             | Maximum allowed query execution time. 
Queries exceeding this limit will be aborted. Value of 0 means no limit.                                                                                              | `[uint64]` |
| `--query-max-plans=1000`                                                        | Maximum number of generated plans for a query.                                                                                                                                                                   | `[uint64]` |
| `--query-modules-directory=/usr/lib/memgraph/query_modules`                     | Directory where modules with custom query procedures are stored. NOTE: Multiple comma-separated directories can be defined. The flag is ignored on coordinator instances in a [high availability](https://memgraph.com/docs/clustering/high-availability) setup.                                                                                      | `[string]` |
| `--query-plan-cache-max-size=1000`                                              | Maximum number of query plans to cache.                                                                                                                                                                          | `[int32]`  |
| `--query-vertex-count-to-expand-existing=10`                                    | Maximum count of indexed vertices which provoke indexed lookup and then expand to existing, 
instead of a regular expand. Default is 10, to turn off use -1.                                                 | `[int64]`  |

### Storage

This section contains the list of flags that are used to configure storage usage
in Memgraph.

| Flag                                                          | Description                                                                                                                        | Type       |
|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|------------|
| `--storage-delta-on-identical-property-update=true`             | Controls whether a delta object will be created if a property is updated with the same value.                                      | `[bool]`   |
| `--storage-gc-cycle-sec=30`                                     | Storage garbage collector interval (in seconds).                                                                                   | `[uint64]` |
| `--storage-python-gc-cycle-sec=180`                             | Interval for manual complete garbage collection in Python (in seconds).                                                            | `[uint64]` |
| `--storage-items-per-batch=1000000`                             | The number of edges and vertices stored in a batch in a snapshot file.                                                             | `[uint64]` |
| `--storage-parallel-schema-recovery=false`                      | Controls whether the indices and constraints creation can be done in a multithreaded fashion during recovery.                      | `[bool]`   |
| `--storage-properties-on-edges=true`                            | Controls whether edges have properties.                                                                                            | `[bool]`   |
| `--storage-omit-vector-index-properties-on-return=false`        | When `true`, properties backed by a vector index (for example embeddings) are omitted when a whole node or relationship is returned; they stay accessible via explicit property access. Can also be changed at runtime via `SET DATABASE SETTING 'storage.omit_vector_index_properties_on_return' TO 'true'`. | `[bool]`   |
| `--storage-recovery-thread-count`                               | The number of threads used to recover persisted data from disk. Defaults to using system's maximum thread count.                   | `[uint64]` |
| `--storage-snapshot-interval-sec=300`                           | Storage snapshot creation interval (in seconds). Set to 0 to disable periodic snapshot creation.                                   | `[uint64]` |
| `--storage-snapshot-interval="300`"                             | Define periodic snapshot schedule via 6-field cron expression (with seconds) or as a period in seconds. Set to empty string to disable. | `[string]` |
| `--storage-snapshot-on-exit=true`                               | Controls whether the storage creates another snapshot on exit.                                                                     | `[bool]`   |
| `--storage-allow-recovery-failure=false`                        | If `true`, an in-memory database that fails durability recovery on startup comes up in a `broken` state instead of crashing the process. Broken databases reject data queries until recovered via `RECOVER SNAPSHOT`. See [recovery failure handling](https://memgraph.com/docs/fundamentals/data-durability#recovery-failure-handling). | `[bool]`   |
| `--storage-snapshot-retention-count=3`                          | The number of snapshots that should always be kept.                                                                                | `[uint64]` |
| `--storage-parallel-snapshot-creation=false`                    | Controls whether the snapshot creation can be done in a multi-threaded fashion.                                                    | `[bool]`   |
| `--storage-snapshot-thread-count`                               | The number of threads used to create snapshots. Defaults to using system's maximum thread count.                                   | `[uint64]` |
| `--storage-snapshot-writeback-window-mib`                       | How large a chunk of a snapshot is written to disk at a time, in MiB. Defaults to 32. Set to 0 to disable. See [limiting the impact of snapshots on queries](https://memgraph.com/docs/fundamentals/data-durability#limiting-the-impact-of-snapshots-on-queries). | `[uint64]` |
| `--storage-wal-enabled=true`                                    | Controls whether the storage uses write-ahead-logging. To enable WAL, periodic snapshots must be enabled.                          | `[bool]`   |
| `--storage-wal-file-flush-every-n-tx=100000`                    | Issue a 'fsync' call after this amount of transactions are written to the WAL file. Set to 1 for fully synchronous operation.      | `[uint64]` |
| `--storage-wal-file-size-kib=20480`                             | Minimum file size of each WAL file.                                                                                                | `[uint64]` |
| `--storage-mode=IN_MEMORY_TRANSACTIONAL`                        | The storage mode Memgraph will run on startup. Can be IN_MEMORY_TRANSACTIONAL, IN_MEMORY_ANALYTICAL or ON_DISK_TRANSACTIONAL. A data instance in a high availability cluster cannot start in IN_MEMORY_ANALYTICAL; it can only [switch to it at runtime](https://memgraph.com/docs/clustering/high-availability/analytical-import). | `[string]` |
| `--storage-enable-schema-metadata=false`                        | Facilitates the utilization of a specialized cache designed to store specific metadata related to the database.                    | `[bool]`   |
| `--storage-enable-edges-metadata=false`                         | Utilizes additional memory to store metadata related to edges. This metadata is used to speed up id based lookups on edges.        | `[bool]`   |
| `--storage-light-edge=false`                                    | Stores edges as lightweight objects to reduce memory footprint (saves ~24B per edge by removing the dedicated edge container). Implies `--storage-properties-on-edges=true`. Direct edge lookups by ID become slower; pair with `--storage-enable-edges-metadata=true` for such workloads. In-memory storage modes only. | `[bool]`   |
| `--storage-automatic-label-index-creation-enabled=false`        | Enables automatic creation of indices on labels. Only usable in IN_MEMORY_TRANSACTIONAL mode.                                      | `[bool]`   |
| `--storage-automatic-edge-type-index-creation-enabled=false`    | Enables automatic creation of indices on edge types. Only usable in IN_MEMORY_TRANSACTIONAL mode.                                  | `[bool]`   |
| `--storage-property-store-compression-enabled=false`            | Controls whether the properties should be compressed in the storage.                                                               | `[bool]`   |
| `--storage-property-store-compression-level=mid`                | Controls property store compression level. Allowed values: low, mid, high                                                          | `[string]` |
| `--storage-floating-point-resolution-bits=64`                   | Max bits for floating-point property storage. Allowed values: 16, 32, 64. Lower values save memory but reduce precision.           | `[uint64]` |
| `--storage-access-timeout-sec=1`                                | Storage access timeout in seconds. Used to fine-tune the responsiveness and guard against queries indefinitely waiting. Can also be changed at runtime via `SET DATABASE SETTING 'storage.access_timeout_sec' TO 'value'`. Valid range: [1, 1000000]. | `[uint64]` |
| `--storage-backup-dir-enabled=true`                             | Controls whether `.old` directory will be used to store backup.                                                                    | `[bool]`   |
| `--storage-rocksdb-info-log-level=INFO_LEVEL`                   | Verbosity of the RocksDB info logs. Allowed values: `DEBUG_LEVEL`, `INFO_LEVEL`, `WARN_LEVEL`, `ERROR_LEVEL`, `FATAL_LEVEL`, `HEADER_LEVEL`. | `[string]` |
| `--storage-rocksdb-keep-log-file-num=1000`                      | Maximum number of RocksDB info log files kept per RocksDB instance. Every restart rolls the current info log and older ones are deleted. Valid range: [1, 2^64-1]. | `[uint64]` |
| `--storage-rocksdb-enable-thread-tracking=false`                | Enables RocksDB thread status tracking for the on-disk storage. Disabled by default to reduce `gettimeofday`/`gettid` syscall overhead. | `[bool]`   |

> **Info**
>
> `--storage-rocksdb-info-log-level` and `--storage-rocksdb-keep-log-file-num`
> apply to **every** RocksDB instance Memgraph opens, not just the one backing the
> `ON_DISK_TRANSACTIONAL` storage mode. That includes the key-value stores holding
> authentication data, triggers, streams, settings, and replication and high
> availability state. Each instance keeps its own info logs (`LOG`, `LOG.old.*`)
> in its own directory, so the limit is per instance and not per Memgraph
> process.
>
> Every restart rolls the current info log into a new file, so on deployments with
> constrained disk space and frequent restarts it is worth lowering
> `--storage-rocksdb-keep-log-file-num` from the default of `1000`.

### Streams

This section contains the list of flags that are used to configure stream
connections in Memgraph.

| Flag                                     | Description                                                                                                 | Type       |
|------------------------------------------|-------------------------------------------------------------------------------------------------------------|------------|
| `--kafka-bootstrap-servers`                | List of Kafka brokers as a comma separated list of broker `host` or `host:port`.                            | `[string]` |
| `--pulsar-service-url`                     | The service URL that will allow Memgraph to locate the Pulsar cluster.                                      | `[string]` |
| `--stream-transaction-conflict-retries=30` | Number of times to retry a conflicting transaction of a stream.                                             | `[uint32]` |
| `--stream-transaction-retry-interval=500`  | The interval to wait (measured in milliseconds) before retrying to execute again a conflicting transaction. | `[uint32]` |

### AWS

This section contains the list of flags that are used when connecting to S3-compatible storage.

| Flag                                       | Description                                                                                                 | Type       |
|--------------------------------------------|-------------------------------------------------------------------------------------------------------------|------------|
| `--aws-region`                             | AWS region in which your S3 service is located.                                                             | `[string]` |
| `--aws-access-key`                         | Access key used to READ the file from S3.                                                                   | `[string]` |
| `--aws-secret-key`                         | Secret key used to READ the file from S3.                                                                   | `[string]` |
| `--aws-endpoint-url`                       | URL on which S3 can be accessed (if using some other S3-compatible storage).                                | `[string]` |

### Other

This section contains the list of all other relevant flags used within Memgraph.

| Flag                                            | Description                                                                                                                                                                                                                                                                                                                                                  | Type       |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------- |
| `--allow-load-csv=true`                         | Controls whether LOAD CSV clause is allowed in queries.                                                                                                                                                                                                                                                                                                      | `[bool]`   |
| `--also-log-to-stderr=false`                    | Log messages go to stderr in addition to logfiles.                                                                                                                                                                                                                                                                                                           | `[bool]`   |
| `--data-directory=/var/lib/memgraph`            | Path to directory in which to save all permanent data.                                                                                                                                                                                                                                                                                                       | `[string]` |
| `--data-dir-lock-acquisition-timeout-sec=30`    | Timeout (in seconds) for retrying the acquisition of a file lock on the data directory during startup. When a Memgraph instance starts, it acquires a file lock on its data directory. If another process still holds the lock (e.g., a previous instance hasn't fully shut down, or lock release is delayed on a distributed storage system like CephFS), Memgraph will retry acquiring the lock until this timeout is reached. Set to `0` to fail immediately without retrying. | `[uint32]` |
| `--data-recovery-on-startup=true`               | Facilitates recovery of one or more individual databases and their contents during startup. Replaces `--storage-recover-on-startup`, which no longer works (see [deprecated features](https://memgraph.com/docs/database-management/upgrades/deprecated-features))                                                                                                                                                                                                                          | `[bool]`   |
| `--debug-query-plans=false`                     | Enable DEBUG logging of potential query plans.                                                                                                                                                                                                                                                                                                               | `[string]` |
| `--delta-chain-cache-threshold=128`             | The minimum number of deltas worth caching when rebuilding a certain object's state. Useful when executing parallel transactions dependent on changes of a frequently changed graph object, to lower CPU usage. Must be a positive non-zero integer.                                                                                                         | `[uint64]` |
| `--file-download-conn-timeout-sec`              | The timeout for establishing a connection to the remote server when downloading a file.                                                                                                                                                                                                                                                                      | `[uint64]` |
| `--flag-file`                                   | Path to the additional configuration file, overrides the default configuration settings.                                                                                                                                                                                                                                                                     | `[string]` |
| `--help`                                        | Show help on all flags and exit. The default values is `false`.                                                                                                                                                                                                                                                                                              | `[bool]`   |
| `--help-xml`                                    | Produce an XML version of help and exit. The default values is `false`.                                                                                                                                                                                                                                                                                      | `[bool]`   |
| `--init-file`                                   | Path to the CYPHERL file which contains queries that need to be executed before the Bolt server starts, such as creating users. Not supported on [coordinator instances](https://memgraph.com/docs/clustering/high-availability/how-high-availability-works#coordinator-instance-implementation) or on [data instances running in HA mode](https://memgraph.com/docs/clustering/high-availability/how-high-availability-works#data-instance-implementation).                                                                                       | `[string]` |
| `--init-data-file`                              | Path to the CYPHERL file, which contains queries that need to be executed after the Bolt server starts. Not supported on [coordinator instances](https://memgraph.com/docs/clustering/high-availability/how-high-availability-works#coordinator-instance-implementation) or on [data instances running in HA mode](https://memgraph.com/docs/clustering/high-availability/how-high-availability-works#data-instance-implementation).                                                                                                               | `[string]` |
| `--isolation-level=SNAPSHOT_ISOLATION`          | Isolation level used for the transactions. Allowed values: SNAPSHOT_ISOLATION, READ_COMMITTED, READ_UNCOMMITTED.                                                                                                                                                                                                                                             | `[string]` |
| `--log-failed-queries=false`                    | Log each failed query with a `[failed-query]` tag at `ERROR` level. See [Slow and failed query logging](https://memgraph.com/docs/database-management/logs#slow-and-failed-query-logging).                                                                                                                                                                                            | `[bool]`   |
| `--log-file=/var/log/memgraph/memgraph.log`     | Path to where the log should be stored. If set to an empty string (`--log-file=`), no logs will be saved.                                                                                                                                                                                                                                                    | `[string]` |
| `--log-level=WARNING`                           | Minimum log level. Allowed values: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL.                                                                                                                                                                                                                                                                             | `[string]` |
| `--log-min-duration-ms=-1`                      | Log successful queries whose `parse + plan + execute` time (ms) reaches this threshold with a `[slow-query]` tag at `WARNING` level. `-1` disables; `0` logs every successful query. See [Slow and failed query logging](https://memgraph.com/docs/database-management/logs#slow-and-failed-query-logging).                                                                           | `[int64]`  |
| `--log-query-plan=true`                         | Append the query's EXPLAIN plan to its `[slow-query]` log line. See [Slow and failed query logging](https://memgraph.com/docs/database-management/logs#slow-and-failed-query-logging).                                                                                                                                                                                                | `[bool]`   |
| `--logger-type=sync`                            | Type of logger used by Memgraph. Allowed values: `sync`, `async`. When set to `async`, log messages are buffered and written in a background thread, reducing the performance impact of logging on query execution.                                                                                                                                          | `[string]` |
| `--log-retention-days=35`                       | Controls for how many days daily log files will be preserved. Allowed values: 1–1000000.                                                                                                                                                                                                                                                                     | `[uint64]` |
| `--memory-limit=0`                              | Total memory limit in MiB. Set to 0 to use the default values which are 100% of the physical memory if the swap is enabled and 90% of the physical memory otherwise.                                                                                                                                                                                         | `[uint64]` |
| `--metrics-address="0.0.0.0"`                   | Host for HTTP server for exposing metrics.                                                                                                                                                                                                                                                                                                                   | `[string]` |
| `--metrics-format=OpenMetrics`                  | Format of the metrics HTTP endpoint. Allowed values: `OpenMetrics`, `JSON`. The `JSON` format is deprecated and will be removed in a future release. See [monitoring](https://memgraph.com/docs/database-management/monitoring#metrics-tracking-via-http-server-enterprise-edition) for details. | `[string]` |
| `--metrics-port=9091`                           | Port for HTTP server for exposing metrics.                                                                                                                                                                                                                                                                                                                   | `[int32]` |
| `--memory-warning-threshold=1024`               | Memory warning threshold, in MB. If Memgraph detects there is less available RAM it will log a warning. 
Set to 0 to disable.                                                                                                                                                                                                                            | `[uint64]` |
| `--monitoring-address="0.0.0.0"`                | IP address where the Memgraph's monitoring WebSocket server should listen.                                                                                                                                                                                                                                                                                   | `[string]` |
| `--monitoring-port=7444`                        | Port on which the Memgraph's monitoring WebSocket server should listen.                                                                                                                                                                                                                                                                                      | `[int32]`  |
| `--password-encryption-algorithm=bcrypt`        | Algorithm used for password encryption. Defaults to BCrypt. Allowed values: `bcrypt`, `sha256`, `sha256-multiple` (SHA256 with multiple iterations)                                                                                                                                                                                                          | `[string]` |
| `--replication-replica-check-frequency-sec`     | The time duration in seconds between two replica checks/pings. If < 1, replicas will not be checked at all and the replica will never be recovered. The MAIN instance allocates a new thread for each REPLICA.                                                                                                                                               | `[uint64]` |
| `--replication-restore-state-on-startup=true`   | Set to `true` when initializing an instance to restore the replication role and configuration upon restart.                                                                                                                                                                                                                                                  | `[bool]`   |
| `--schema-info-enabled=false`                   | Set to `true` to enable run-time schema info tracking.                                                                                                                                                                                                                                                                                                       | `[bool]`   |
| `--strict-flag-check=false`                     | If `true`, Memgraph will error and exit when suspicious positional arguments are detected (e.g. `--bool-flag false` instead of `--bool-flag=false`). If `false`, a warning is logged instead.                                                                                                                                                                | `[bool]`   |
| `--telemetry-enabled=true`                      | Set to true to enable telemetry. We collect information about the running system (CPU and memory information), information about the database runtime (vertex and edge counts and resource usage), and aggregated statistics about some features of the database (e.g. how many times a feature is used) to allow for an easier improvement of the product.  | `[bool]`   |

### Environment variables

This section contains the list of environment variables that can be used to configure Memgraph.

Before the running of Memgraph, you can set the following environment variables:

| Variable                         | Description                                                                                                                                                                                                                                        | Type       |
|----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
| MEMGRAPH_USER                    | Specifies the username for connecting to Memgraph. If the user does not exist, a new one is created with this username. Manual entry of credentials is always necessary when accessing Memgraph using Memgraph Lab.                                | `[string]` |
| MEMGRAPH_PASSWORD                | Specifies the password for the user. If creating a new user, this password is assigned. For existing users, this setting does not change the password. Manual entry of credentials is always necessary when accessing Memgraph using Memgraph Lab. | `[string]` |
| MEMGRAPH_PASSFILE                | Path to the file that contains the username and password for creating a user. Data in the file should be in the format `username:password`. If your username or password contains `:`, add `\` before it, for example, `us\:ername:password`.      | `[string]` |
| MEMGRAPH_CONFIG                  | Path to the additional configuration file.                                                                                                                                                                                                         | `[string]` |
| MEMGRAPH_MANAGEMENT_PORT         | Port on which data instance management servers or the coordinator management server will be started.                                                                                                                                               | `[int]`    |
| MEMGRAPH_COORDINATOR_PORT        | Port on which Raft servers will be started.                                                                                                                                                                                                        | `[int]`    |
| MEMGRAPH_COORDINATOR_ID          | Unique ID of the Raft server.                                                                                                                                                                                                                      | `[int]`    | 
| MEMGRAPH_NURAFT_LOG_FILE         | Path to the file where NuRaft logs are saved.                                                                                                                                                                                                      | `[string]` |
| MEMGRAPH_COORDINATOR_HOSTNAME    | Instance's hostname. Used as output of the `SHOW INSTANCES` query.                                                                                                                                                                                 | `[string]` |
| MEMGRAPH_HA_CLUSTER_INIT_QUERIES | Path to the file with queries to initialize the HA cluster.                                                                                                                                                                                        | `[string]` |
| MEMGRAPH_BOLT_PORT               | Bolt port used for Bolt server.                                                                                                                                                                                                                    | `[int]`    |
| MEMGRAPH_EXPERIMENTAL_ENABLED    | List of experimental features which the user wants to use.                                                                                                                                                                                         | `[string]` |
| MEMGRAPH_ENTERPRISE_LICENSE      | Memgraph enterprise license key.                                                                                                                                                                                                                   | `[string]` |
| MEMGRAPH_ORGANIZATION_NAME       | Organization name to which Memgraph license key was issued.                                                                                                                                                                                        | `[string]` |

In order to apply the environment variables with Memgraph, you can follow the steps below:

**Docker**

To set the environment variable when running Memgraph with Docker, use the following syntax:

```
docker run -p 7687:7687 -p 7444:7444 -e MEMGRAPH_USER=newUser -e MEMGRAPH_PASSWORD=pass memgraph/memgraph 
```

    The above command will start Memgraph in Docker container and create a user with username `newUser` and password `pass`.

**Docker Compose**

In order to apply the environment variables in when running it with Docker Compose, add environment variables in your docker-compose.yml file:
```yaml
    services:
      memgraph:
        image: "memgraph/memgraph"
        ports:
          - "7687:7687"
          - "7444:7444"
        volumes:
          - mg_lib:/var/lib/memgraph
          - mg_log:/var/log/memgraph
        command: ["--log-level=TRACE"]
        environment:
          - MEMGRAPH_USER=memgraph
          - MEMGRAPH_PASSWORD=memgraph
    volumes:
      mg_lib:
      mg_log:
      mg_etc:
    ```
        ---

        Once you've added the environment variables, restart the instance using 
        Docker Compose. First, bring the services down. Place yourself in the 
        terminal in the folder containing the docker-compose.yml file and run 
        the following command:
```
docker-compose down
```
        
        Then bring them back up:
```
docker-compose up -d
```

        This will restart the containers with the updated environment variables.

**Linux**

In order to apply the environment variables in Memgraph, 
    open a service file in your favorite text editor and add the following lines:

```bash
    [Service]
    Environment="MEMGRAPH_USER=memgraph"
    Environment="MEMGRAPH_PASSWORD=memgraph"
```

    The service file should be located at `/lib/systemd/system/memgraph.service`.

    After you have added the environment variables, reload the systemd:

```bash
systemctl daemon-reload
```

    After that you can restart or start the Memgraph instance:

```bash 
systemctl start memgraph
```
    The environment variables will be applied to the Memgraph instance, and user will be created.

## Use `init` flags with Docker

With `init-file` and `init-data-file` configuration
flags, you can execute queries from a
CYPHERL file that need to be executed before or immediately after the Bolt
server starts. The CYPHERL file the `init-file` flag points to is usually used
to create users and set their passwords allowing only authorized users to access
the data in the first run. The CYPHERL file the `init-data-file` points to is
usually used to populate the database.

If you will run Memgraph with Docker, make sure that the `init-file` and
`init-data-file` configuration flags are referring to the files inside the
container before Memgraph starts. Files can't be directly copied into a
container before it's started because the filesystem of the container doesn't
exist until it's actually running. However, you can tackle this by using a
Dockerfile.

In this guide you will learn how to:
- [**Use the `init-file` flag with Docker**](#use-the-init-file-flag-with-docker)
- [**Use the `init-data-file` flag with Docker**](#use-the-init-data-file-flag-with-docker)

> **Note**
>
> If an exception occurs during the execution of init script the queries will continue with execution.

> **Warning**
>
> The `--init-file` and `--init-data-file` flags are **not supported on coordinator instances** in a [high availability](https://memgraph.com/docs/clustering/high-availability) setup, and are also **not supported on data instances running in HA mode** (i.e. when `--management-port` is set). The instance will fail to start if either flag is provided. To bootstrap users or data in an HA cluster, run the queries through the MAIN after the cluster is formed.

### Use the `init-file` flag with Docker

### Create all necessary files

First, create a local directory called `my_init_test` with `auth.cypherl` and
Dockerfile inside it.

Below is the content of the `auth.cypherl` file:

```
CREATE USER memgraph1 IDENTIFIED BY '1234';
```

The Dockerfile should be defined like this:

```bash
FROM memgraph/memgraph:latest

USER root

COPY auth.cypherl /usr/lib/memgraph/auth.cypherl

USER memgraph
```

The above Dockerfile builds an image based on `memgraph/memgraph:latest` image.
For other images, [check Memgraph's Docker
Hub](https://hub.docker.com/u/memgraph). Then, it switches to the user `root` to
be able to copy the local file to the container where Memgraph will be run. Due
to the permissions set, it is recommended to copy it to `/usr/lib/memgraph/` or
any subfolder within that folder. In the end, the user is switched back to
`memgraph`.

### Build the Docker image

Open the terminal, place yourself in the `my_init_test` directory and build the
image called `my_image` with the following command:

```
docker build -t my_image .
```

### Run the Docker image

Once you've built the Docker image, you can run it with the `init-file` flag set
to the appropriate value:

```
docker run -it -p 7687:7687 -p 7444:7444 my_image --init-file=/usr/lib/memgraph/auth.cypherl
```

To check all available flags in Memgraph, refer to [the configuration reference
guide](https://memgraph.com/docs/database-management/configuration).

### Connect to Memgraph

To verify that everything is set up correctly, [run Memgraph
Lab](https://memgraph.com/docs/data-visualization) and connect to
Memgraph. You'll notice that you have
to connect manually and input the correct username and password. This happened
because `auth.cypherl` file was run before the Bolt server started. You can also
run the `SHOW CONFIG` query:

![](https://memgraph.com/docs/pages/database-management/configuration/memgraph-lab-init-file.png)

Notice how the current value of `init_file` is updated with the path to the
CYPHERL file inside the container.

### Use the `init-data-file` flag with Docker

### Create all necessary files

First, create a local directory called `my_init_test` with `data.cypherl` and
Dockerfile inside it.

Below is the content of the `data.cypherl` file:

```
CREATE INDEX ON :__mg_vertex__(__mg_id__);
CREATE (:__mg_vertex__:`Person` {__mg_id__: 0, `name`: "Peter"});
CREATE (:__mg_vertex__:`Team` {__mg_id__: 1, `name`: "Engineering"});
CREATE (:__mg_vertex__:`Repository` {__mg_id__: 2, `name`: "Memgraph"});
CREATE (:__mg_vertex__:`Repository` {__mg_id__: 3, `name`: "MAGE"});
CREATE (:__mg_vertex__:`Repository` {__mg_id__: 4, `name`: "GQLAlchemy"});
CREATE (:__mg_vertex__:`Company` {__mg_id__: 5, `name`: "Memgraph"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 6, `name`: "welcome_to_engineering.txt"});
CREATE (:__mg_vertex__:`Storage` {__mg_id__: 7, `name`: "Google Drive"});
CREATE (:__mg_vertex__:`Storage` {__mg_id__: 8, `name`: "Notion"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 9, `name`: "welcome_to_memgraph.txt"});
CREATE (:__mg_vertex__:`Person` {__mg_id__: 10, `name`: "Carl"});
CREATE (:__mg_vertex__:`Folder` {__mg_id__: 11, `name`: "engineering_folder"});
CREATE (:__mg_vertex__:`Person` {__mg_id__: 12, `name`: "Anna"});
CREATE (:__mg_vertex__:`Folder` {__mg_id__: 13, `name`: "operations_folder"});
CREATE (:__mg_vertex__:`Team` {__mg_id__: 14, `name`: "Operations"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 15, `name`: "operations101.txt"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 16, `name`: "expenses2022.csv"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 17, `name`: "salaries2022.csv"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 18, `name`: "engineering101.txt"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 19, `name`: "working_with_github.txt"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 20, `name`: "working_with_notion.txt"});
CREATE (:__mg_vertex__:`Team` {__mg_id__: 21, `name`: "Marketing"});
CREATE (:__mg_vertex__:`Person` {__mg_id__: 22, `name`: "Julie"});
CREATE (:__mg_vertex__:`Account` {__mg_id__: 23, `name`: "Facebook"});
CREATE (:__mg_vertex__:`Account` {__mg_id__: 24, `name`: "LinkedIn"});
CREATE (:__mg_vertex__:`Account` {__mg_id__: 25, `name`: "HackerNews"});
CREATE (:__mg_vertex__:`File` {__mg_id__: 26, `name`: "welcome_to_marketing.txt"});
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 0 AND v.__mg_id__ = 1 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 0 AND v.__mg_id__ = 5 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 0 AND v.__mg_id__ = 9 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 0 AND v.__mg_id__ = 14 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 1 AND v.__mg_id__ = 2 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 1 AND v.__mg_id__ = 3 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 1 AND v.__mg_id__ = 4 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 1 AND v.__mg_id__ = 6 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 1 AND v.__mg_id__ = 11 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 5 AND v.__mg_id__ = 1 CREATE (u)-[:`HAS_TEAM`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 5 AND v.__mg_id__ = 21 CREATE (u)-[:`HAS_TEAM`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 5 AND v.__mg_id__ = 14 CREATE (u)-[:`HAS_TEAM`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 6 AND v.__mg_id__ = 7 CREATE (u)-[:`IS_STORED_IN`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 6 AND v.__mg_id__ = 8 CREATE (u)-[:`IS_STORED_IN`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 9 AND v.__mg_id__ = 12 CREATE (u)-[:`CREATED_BY`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 10 AND v.__mg_id__ = 1 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 10 AND v.__mg_id__ = 5 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 10 AND v.__mg_id__ = 9 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 11 AND v.__mg_id__ = 7 CREATE (u)-[:`IS_STORED_IN`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 11 AND v.__mg_id__ = 18 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 11 AND v.__mg_id__ = 19 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 11 AND v.__mg_id__ = 20 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 12 AND v.__mg_id__ = 14 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 13 AND v.__mg_id__ = 15 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 13 AND v.__mg_id__ = 16 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 13 AND v.__mg_id__ = 17 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 13 AND v.__mg_id__ = 7 CREATE (u)-[:`IS_STORED_IN`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 14 AND v.__mg_id__ = 13 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 21 AND v.__mg_id__ = 23 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 21 AND v.__mg_id__ = 24 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 21 AND v.__mg_id__ = 25 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 21 AND v.__mg_id__ = 26 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 22 AND v.__mg_id__ = 21 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 22 AND v.__mg_id__ = 5 CREATE (u)-[:`IS_PART_OF`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 22 AND v.__mg_id__ = 9 CREATE (u)-[:`HAS_ACCESS_TO`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 26 AND v.__mg_id__ = 7 CREATE (u)-[:`IS_STORED_IN`]->(v);
MATCH (u:__mg_vertex__), (v:__mg_vertex__) WHERE u.__mg_id__ = 26 AND v.__mg_id__ = 8 CREATE (u)-[:`IS_STORED_IN`]->(v);
DROP INDEX ON :__mg_vertex__(__mg_id__);
MATCH (u) REMOVE u:__mg_vertex__, u.__mg_id__;
```

These Cypher queries will create the *Identity and access management* dataset
available in Memgraph Lab. You can get this CYPHERL file by exporting the
dataset from the Memgraph Lab.

The Dockerfile should be defined like this:

```bash
FROM memgraph/memgraph:latest

USER root

COPY data.cypherl /usr/lib/memgraph/data.cypherl

USER memgraph
```

The above Dockerfile builds an image based on `memgraph/memgraph:latest` image.
For other images, [check Memgraph's Docker
Hub](https://hub.docker.com/u/memgraph). Then, it switches to the user `root` to
be able to copy the local file to the container where Memgraph will be run. Due
to the permissions set, it is recommended to copy it to `/usr/lib/memgraph/` or
any subfolder within that folder. In the end, the user is switched back to
`memgraph`.

### Build the Docker image

Open the terminal, place yourself in the `my_init_test` directory and build the
image called `my_image` with the following command:

```
docker build -t my_image .
```

### Run the Docker image

Once you've built the Docker image, you can run it with the `init-data-file`
flag set to the appropriate value:

```
docker run -it -p 7687:7687 -p 7444:7444 my_image --init-data-file=/usr/lib/memgraph/data.cypherl
```

### Connect to Memgraph

To verify that everything is set up correctly, [run Memgraph
Lab](https://memgraph.com/docs/data-visualization), connect to Memgraph, and run the `SHOW CONFIG` query:

![](https://memgraph.com/docs/pages/database-management/configuration/memgraph-lab-init-data-file.png)

Notice how the database is already populated and the current value of
`init_data_file` is updated with the path to the CYPHERL file inside the
container.
