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
.
You can check the current configuration by using the following query:
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.
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.
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:
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 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
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 |
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 |
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";
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 ; . If the mapping contains whitespace, enclose the flag value with quotation marks. |
--auth-module-executable | [DEPRECATED] Path to the executable that should be used for user authentication/authorization. Replaced by --auth-module-mappings=basic from Memgraph 2.18. |
--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 (opens in a new tab). |
--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 (opens in a new tab). |
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.
Experimental features
This section contains the list of flags that are used to configure experimental features in Memgraph.
Flag | Description |
---|---|
--experimental-enabled=high-availability | Enables high availability mode in Memgraph Enterprise Edition. |
--experimental-enabled=text-search | Enables text search capabilities within Memgraph. |
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. | [uint32] |
--coordinator-port | Raft server's port on coordinator instance. | [uint32] |
--management-port | Port on which replication instances receive messages from coordinator . | [uint32] |
--instance-health-check-frequency-sec=1 | The interval between two health checks that coordinator does on replication instances. | [uint32] |
--instance-down-timeout-sec=5 | Number of seconds that need to pass before replication instance is considered down. Must be greater or equal to the --instance-health-check-frequency-sec . | [uint32] |
--instance-get-uuid-frequency-sec=10 | The interval between two instance uuid checks. | [uint32] |
--nuraft-log-file | Path to the file where NuRaft logs are saved. | [string] |
--ha-durability=true | Enable or disable durability for logs and snapshots. | [bool] |
--coordinator-hostname | Coordinator's instance hostname. Used only in SHOW INSTANCES query. | [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-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. | [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] |
--query-log-directory | Location to store log files for session tracing. | [string] |
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-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-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] |
--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. | [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-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] |
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 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-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] |
--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. | [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. If set to an empty string ("" ), no logs will be saved. | [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 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] |
--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] |
--version | Show version and build info and exit. The default values is false . | [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_HA_DURABILITY | Whether to use durability for coordinator logs and snapshots. | [bool] |
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:
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
.
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:
If an exception occurs during the execution of init script the queries will continue with execution.
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.