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.
When working with Memgraph Platform Docker image, you should pass configuration flags inside of environment variables.
For example, you can start the memgraph
Docker image with docker run memgraph/memgraph --bolt-port=7687 --log-level=TRACE
, but you should start
memgraph-platform
Docker image with 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.
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-executable | Path to the executable that should be used for user authentication/authorization. |
--auth-module-create-user | Controls whether users should be implicitly created on first login or they should be explicitly created manually. |
--auth-module-create-role | Controls whether roles should be implicitly created on first appearance or they should be explicitly created manually. |
--auth-module-manage-roles | Specifies whether the module is used only for authentication (value is false ), or it should be used for both authentication and authorization. |
--auth-module-timeout | 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. |
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] |
--bolt-session-inactivity-timeout=1800 | Time 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.
Query
This section contains the list of flags that are used to configure query execution in Memgraph.
Flag | Description | Type |
---|---|---|
--query-callable-mappings-path | 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. | [bool] |
--query-execution-timeout-sec=180 | 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. | [string] |
--query-plan-cache-ttl=60 | Time to live for cached query plans, in seconds. | [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-gc-cycle-sec=30 | Storage garbage collector interval (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-index-recovery=false | Controls whether the index creation can be done in a multithreaded fashion during recovery. | [bool] |
--storage-properties-on-edges=true | Controls whether edges have properties. | [bool] |
--storage-recover-on-startup=true | Deprecated and replaced with the data_recovery_on_startup flag. Controls whether the storage recovers persisted data on startup. | [bool] |
--storage-recovery-thread-count= | The number of threads used to recover persisted data from disk. | [uint64] |
--storage-snapshot-interval-sec=300 | Storage snapshot creation interval (in seconds). Set to 0 to disable periodic snapshot creation. | [uint64] |
--storage-snapshot-on-exit=true | Controls whether the storage creates another snapshot on exit. | [bool] |
--storage-snapshot-retention-count=3 | The number of snapshots that should always be kept. | [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] |
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] |
Other
This section contains the list of all other releant 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_recovery_on_startup=true | Facilitates recovery of one or more individual databases and their contents during startup. Replaces --storage-recover-on-startup | [bool] |
--delta-chain-cache-threshold=128 | The 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-file | Path to the CYPHERL file which contains queries that need to be executed before the Bolt server starts, such as creating users. | [string] |
--init-data-file | Path to the CYPHERL file, which contains queries that need to be executed after the Bolt server starts. | [string] |
--isolation-level=SNAPSHOT_ISOLATION | Isolation level used for the transactions. Allowed values: SNAPSHOT_ISOLATION, READ_COMMITTED, READ_UNCOMMITTED. | [string] |
--log-file=/var/log/memgraph/memgraph.log | Path to where the log should be stored. | [string] |
--log-level=WARNING | Minimum log level. Allowed values: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL. | [string] |
--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 | Host for HTTP server for exposing metrics. | [string] |
--metrics-port | Port for HTTP server for exposing metrics. | [uint64] |
--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 WebsScket server should listen. | [string] |
--monitoring_port=7444 | Port on which the Memgraph's monitoring WebsScket 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-delay-sec | The time duration in seconds between two replica checks/pings. If < 1, replicas will not be checked at all. The MAIN instance allocates a new thread for each REPLICA. | [uint64] |
--replication-restore-state-on-startup | Set to true when initializing an instance to restore the replication role and configuration upon restart. | [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
Variable | Description | Type |
---|---|---|
MEMGRAPH_USER | Username | [string] |
MEMGRAPH_PASSWORD | User password | [string] |
MEMGRAPH_PASSFILE | Path 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 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 |
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.