Configuration settings

Configuration settings

The main Memgraph configuration file is available in /etc/memgraph/memgraph.conf. You can modify that file to suit your specific needs. Additional configuration can be specified by including another configuration file, in a file pointed to by the MEMGRAPH_CONFIG environment variable or by passing arguments on the command line.

For example, you can start the memgraph Docker image with docker run memgraph/memgraph --bolt-port=7687 --log-level=TRACE.

If you are working with Memgraph Platform Docker image, you should pass configuration flags inside of environment variables, e.g. docker run -p 7687:7687 -p 7444:7444 -p 3000:3000 -e MEMGRAPH="--bolt-port=7687 --log-level=TRACE" memgraph/memgraph-platform.

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

You can check the current configuration by using the following query (privilege level CONFIG is required):

SHOW CONFIG;

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.

Audit log

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

FlagDescription
--audit-enabledEnables audit logging.
--audit-buffer-sizeControls the in-memory buffer size used for audit logs.
--audit-buffer-flush-interval-msControls 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.

FlagDescription
--auth-module-executablePath to the executable that should be used for user authentication/authorization.
--auth-module-create-missing-userDEPRECATED No authentication data is modified by the auth module
--auth-module-create-missing-roleDEPRECATED No authentication data is modified by the auth module
--auth-module-manage-rolesDEPRECATED No authentication data is modified by the auth module
--auth-module-timeout-msSpecifies the maximum time that Memgraph will wait for a response from the external auth module.
--auth-password-permit-nullCan be set to false to disable null passwords.
--auth-password-strength-regexThe regular expression that should be used to match the entire entered password to ensure its strength.
--auth-user-or-role-regexSet to the regular expression that each user or role name must fulfill.

Bolt

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

FlagDescriptionType
--bolt-address=0.0.0.0IP 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=7687Port on which the Bolt server should listen.[int32]
--bolt-server-name-for-init=Neo4j/v5.11.0 compatible graph database server - MemgraphServer name which the database should send to the client in the Bolt INIT message.[string]
--bolt-session-inactivity-timeout=1800Time in seconds after which inactive Bolt sessions will be closed.[int32]

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.

Experimental features

This section contains the list of flags that are used to configure experimental features in Memgraph.

FlagDescription
--experimental-enabled=high-availabilityEnables high availability mode in Memgraph Enterprise Edition.
--experimental-enabled=system-replicationEnables system replication, including authentication and multi-tenancy replication in the Enterprise Edition.
--experimental-enabled=text-searchEnables text search capabilities within Memgraph.

High availability

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

FlagDescriptionType
--coordinator-idId of the coordinator instance.[uint32]
--coordinator-portPort used for Raft server on coordinator instance.[uint32]
--management-portPort on which replication instances receive messages from coordinator .[uint32]
--instance-health-check-frequency-sec=1The interval between two health checks that coordinator does on replication instances.[uint32]
--instance-down-timeout-sec=5Number of seconds that need to pass before replication instance is considered down.[uint32]
--instance-get-uuid-frequency-sec=10The interval between two instance uuid checks.[uint32]

Query

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

FlagDescriptionType
--cartesian-product-enabled=trueEnforces whether cartesian product matching is going to be used in the plans.[bool]
--query-callable-mappings-path=/etc/memgraph/apoc_compatibility_mappings.jsonPath to the JSON file that contains possible alias mappings for query procedures in the form of key-value pairs.[string]
--query-cost-planner=trueUse the cost-estimating query planner.[bool]
--query-execution-timeout-sec=600Maximum allowed query execution time.
Queries exceeding this limit will be aborted. Value of 0 means no limit.
[uint64]
--query-max-plans=1000Maximum number of generated plans for a query.[uint64]
--query-modules-directory=/usr/lib/memgraph/query_modulesDirectory where modules with custom query procedures are stored. NOTE: Multiple comma-separated directories can be defined.[string]
--query-plan-cache-max-size=1000Maximum number of query plans to cache.[int32]
--query-vertex-count-to-expand-existing=10Maximum 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.

FlagDescriptionType
--storage-delta-on-identical-property-update=trueControls whether a delta object will be created if a property is updated with the same value.[bool]
--storage-gc-cycle-sec=30Storage garbage collector interval (in seconds).[uint64]
--storage-python-gc-cycle-sec=180Interval for manual complete garbage collection in Python (in seconds).[uint64]
--storage-items-per-batch=1000000The number of edges and vertices stored in a batch in a snapshot file.[uint64]
--storage-parallel-index-recovery=false[DEPRECATED] Controls whether the index creation can be done in a multithreaded fashion during recovery.[bool]
--storage-parallel-schema-recovery=falseControls whether the indices and constraints creation can be done in a multithreaded fashion during recovery.[bool]
--storage-properties-on-edges=trueControls whether edges have properties.[bool]
--storage-recover-on-startup=trueDeprecated and replaced with the data_recovery_on_startup flag. Controls whether the storage recovers persisted data on startup.[bool]
--storage-recovery-thread-countThe number of threads used to recover persisted data from disk. Defaults to using system's maximum thread count.[uint64]
--storage-snapshot-interval-sec=300Storage snapshot creation interval (in seconds). Set to 0 to disable periodic snapshot creation.[uint64]
--storage-snapshot-on-exit=trueControls whether the storage creates another snapshot on exit.[bool]
--storage-snapshot-retention-count=3The number of snapshots that should always be kept.[uint64]
--storage-wal-enabled=trueControls whether the storage uses write-ahead-logging. To enable WAL, periodic snapshots must be enabled.[bool]
--storage-wal-file-flush-every-n-tx=100000Issue 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=20480Minimum file size of each WAL file.[uint64]
--storage-mode=IN_MEMORY_TRANSACTIONALThe storage mode Memgraph will run on startup. Can be IN_MEMORY_TRANSACTIONAL, IN_MEMORY_ANALYTICAL or ON_DISK_TRANSACTIONAL.[string]
--storage-enable-schema-metadata=falseFacilitates the utilization of a specialized cache designed to store specific metadata related to the database.[bool]
--storage-enable-edges-metadata=falseUtilizes additional memory to store metadata related to edges. This metadata is used to speed up id based lookups on edges.[bool]
--storage-automatic-label-index-creation-enabled=falseEnables creating indices on labels automatically.[bool]
--storage-automatic-edge-type-index-creation-enabled=falseEnables creating indices on edge-types automatically.[bool]

Streams

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

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

Other

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

FlagDescriptionType
--allow-load-csv=trueControls whether LOAD CSV clause is allowed in queries.[bool]
--also-log-to-stderr=falseLog messages go to stderr in addition to logfiles.[bool]
--data-directory=/var/lib/memgraphPath to directory in which to save all permanent data.[string]
--data-recovery-on-startup=trueFacilitates recovery of one or more individual databases and their contents during startup. Replaces --storage-recover-on-startup[bool]
--delta-chain-cache-threshold=128The minimum number of deltas worth caching when rebuilding a certain object's state. Useful when executing parallel transactions dependant on changes of a frequently changed graph object, to lower CPU usage. Must be a positive non-zero integer.[uint64]
--init-filePath to the CYPHERL file which contains queries that need to be executed before the Bolt server starts, such as creating users.[string]
--init-data-filePath to the CYPHERL file, which contains queries that need to be executed after the Bolt server starts.[string]
--isolation-level=SNAPSHOT_ISOLATIONIsolation level used for the transactions. Allowed values: SNAPSHOT_ISOLATION, READ_COMMITTED, READ_UNCOMMITTED.[string]
--log-file=/var/log/memgraph/memgraph.logPath to where the log should be stored. If set to an empty string (""), no logs will be saved.[string]
--log-level=WARNINGMinimum log level. Allowed values: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL.[string]
--memory-limit=0Total 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-addressHost for HTTP server for exposing metrics.[string]
--metrics-portPort for HTTP server for exposing metrics.[uint64]
--memory-warning-threshold=1024Memory 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 WebsScket server should listen.[string]
--monitoring-port=7444Port on which the Memgraph's monitoring WebsScket server should listen.[int32]
--password-encryption-algorithm=bcryptAlgorithm used for password encryption. Defaults to BCrypt. Allowed values: bcrypt, sha256, sha256-multiple (SHA256 with multiple iterations)[string]
--replication-replica-check-frequency-secThe 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-startupSet to true when initializing an instance to restore the replication role and configuration upon restart.[bool]
--telemetry-enabled=trueSet 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

VariableDescriptionType
MEMGRAPH_USERUsername[string]
MEMGRAPH_PASSWORDUser password[string]
MEMGRAPH_PASSFILEPath to file that contains username and password for creating user. Data in file should be in format username:password if your username or password contains : just add \ before for example us\:ername:password[string]

Additional configuration inclusion

You can define additional configuration files in the main configuration file or within a Docker command in the terminal. Additional files are processed after the main configuration file and they override the main configuration file. Additional configuration files are specified with the --flag-file flag.

Example:

--flag-file=another.conf

Check configuration

Check the current configuration by running the SHOW CONFIG; query.

Change the configuration

Some configuration settings can be changed during runtime, while others need to be changed in the configuration file or by passing configuration flags.

During runtime

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

Setting nameDescriptionPersistent between runs
organization.nameName of the organization using the instance of Memgraph (used for verifying the license key).yes
enterprise.licenseLicense key for Memgraph Enterprise.yes
server.nameBolt server name.yes
query.timeoutMaximum allowed query execution time. Value of 0 means no limit.yes
log.levelMinimum log level. Allowed values: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL.no
log.to_stderrLog messages go to stderr in addition to logfiles.no
cartesian-product-enabledEnforces cartesian product operator during query matching.no

All settings can be fetched by calling the following query:

SHOW DATABASE SETTINGS;

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

SHOW DATABASE SETTING "setting.name";

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

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

Using flags and config file

Changing the configuration settings for Memgraph differes if you are using Memgraph with Docker or if it was installed with Linux - Ubuntu, Debian, RPM package, or WSL.

You can customize the configuration by passing configuration options within the docker run command.

If you are working with the memgraph-platform image, you should pass configuration options with environment variables.

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 like this:

docker run -p 7687:7687 -p 3000:3000 -p 7444:7444 -e MEMGRAPH="--memory-limit=50 --log-level=TRACE" --name memgraph memgraph/memgraph-platform

When you are working with memgraph or memgraph-mage images, you should pass configuration options as arguments.

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

You can also change the configuration within the 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 continer

Enter the Docker container with the following command:

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 vim

Edit the configuration file

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

Restart the intance

Run the following command:

docker restart <CONTAINER ID>

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

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:

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 (opens in a new tab). 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.

Connect to Memgraph

To verify that everything is set up correctly, run Memgraph Lab 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:

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:

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 (opens in a new tab). 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, connect to Memgraph, and run the SHOW CONFIG query:

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.