Install Memgraph Lab and connect to a database
We recommend you use the Memgraph Platform and get the complete streaming graph application platform that includes:
- Memgraph - the database that holds your data
- Memgraph Lab - visual user interface for running queries and visualizing graph data
- mgconsole - command-line interface for running queries
- MAGE - graph algorithms and modules library
After running the image, mgconsole will open in the terminal while Memgraph Lab
is available on http://localhost:3000
.
If you want to install Memgraph Lab as a desktop application, check out the installation instructions for Windows, macOS and Linux, and if you have a public Memgraph database instance you can access the Lab web application at https://lab.memgraph.com/ (opens in a new tab).
Install Memgraph Lab desktop application
Download and install Memgraph
Memgraph Lab requires a running Memgraph database instance.
If you installed Memgraph using Docker and wish to connect to it with the
Memgraph Lab desktop application, ensure that ports 7687, used for instance
connections (-p 7687:7687
), and 7444, used for logs (-p 7444:7444
), are
exposed in the docker run ...
command.
Connecting Memgraph Lab to Memgraph may vary depending on the deployment method
or operating system. The handling of the QUICK_CONNECT_MG_HOST
environment
variable varies by operating
system.
Download Memgraph Lab
Visit the Download Hub (opens in a new tab) and download the Memgraph Lab desktop application.
Install Memgraph Lab
You can install Memgraph Lab by double clicking the downloaded installer and following the instructions.
If you downloaded Memgraph Lab on Linux, you can execute:
sudo dpkg -i MemgraphLab-x.x.x.deb
Set up connection
After you start Memgraph Lab, you should be presented with a login screen.
These are the default settings:
- Leave the
Username
andPassword
fields empty. - The
Host
field can be eitherlocalhost
,127.0.0.1
or0.0.0.0
, or change it appropriately. - The
Port
field should be7687
. Every Memgraph instance is listening on this port by default. - The
Encrypted
option should be disabled and displaySSL Off
by default.
Connect
Click on Connect, and you should be presented with the following dashboard:
Congratulations! You have successfully installed Memgraph Lab and connected it to Memgraph. You are now ready to start building your graph and querying it.
You might receive the following error message when trying to connect.
In this case, make sure that Memgraph is properly up and running and that you have entered the correct port number.
Execute queries
Now, you can execute Cypher queries on Memgraph. Open the Query tab, located in the left sidebar, copy the following query and press the Run query button:
CREATE (u:User {name: "Alice"})-[:Likes]->(m:Software {name: "Memgraph"});
The query above will create 2 nodes in the database, one labeled "User" with name "Alice" and the other labeled "Software" with name "Memgraph". It will also create a relationship that "Alice" likes "Memgraph".
To find created nodes and relationships, execute the following query:
MATCH p=()-[]->() RETURN p;
You should get the following result:
Run Memgraph Lab with Docker
Run the Memgraph Lab Docker image using the following command:
docker run -d -p 3000:3000 --name lab memgraph/lab
Once the container is up you can access Memgraph Lab on localhost:3000 (opens in a new tab).
Issues when connecting to Memgraph
Memgraph Lab detects if Memgraph is running on localhost:7687
by default for the Quick Connect.
The environment variables that are responsible for Quick Connect working as expected are QUICK_CONNECT_MG_HOST
and QUICK_CONNECT_MG_PORT
. The handling of the
QUICK_CONNECT_MG_HOST
environment variable differs based on the operating
system:
-
Mac or Windows: The
host.docker.internal
hostname allows Docker containers to connect to the host machine. Set this as the value forQUICK_CONNECT_MG_HOST
when running Lab on Mac or Windows to enable connection to Memgraph running on the host:docker run -d -p 3000:3000 -e QUICK_CONNECT_MG_HOST=host.docker.internal --name lab memgraph/lab
-
Linux: There's no need to set
QUICK_CONNECT_MG_HOST
as it defaults tolocalhost
, assuming Memgraph is running locally on the host machine.
You can also use the QUICK_CONNECT_MG_PORT
environment variable to specify the
quick connect port number, e.g. - e QUICK_CONNECT_MG_PORT=7688
.
To connect to a running Memgraph instance, you don't need to set
QUICK_CONNECT_MG_HOST
to host.docker.internal
. Instead, create a new
connection in Memgraph Lab and specify host.docker.internal
as the Host.
Environment variables
The desktop application version of Memgraph Lab does not support receiving environment variables.
Configure Memgraph Lab using the following environment variables when running it through Docker, including Docker Compose:
Variable | Description | Type | Default |
---|---|---|---|
QUERY_MAX_LEN | Max length of a Cypher query | integer | 5000 |
MODULE_NAME_MAX_LEN | Max length of the query module name | integer | 1000 |
MODULE_CONTENT_MAX_LEN | Max length of a query module content | integer | 50000 |
STREAM_NAME_MAX_LEN | Max length of the stream name | integer | 500 |
QUERY_VALIDATION_IS_ENABLED | State of query validation | boolean | false |
STREAM_VALIDATION_IS_ENABLED | State of stream validation | boolean | false |
NODE_LABEL_MAX_LEN | Max length of the node label | integer | 1000 |
NODE_LABEL_VALIDATION_IS_ENABLED | State of node label validation | boolean | false |
NODE_PROPERTY_MAX_LEN | Max length of the node property | integer | 1000 |
NODE_PROPERTY_VALIDATION_IS_ENABLED | State of node property validation | boolean | false |
MODULE_VALIDATION_IS_ENABLED | State of module validation | boolean | false |
QUICK_CONNECT_IS_DISABLED | State of quick connect feature | boolean | false |
QUICK_CONNECT_MG_HOST | Host address for quick connect | string | 127.0.0.1 |
QUICK_CONNECT_MG_PORT | Port for quick connect | integer | 7687 |
REQUEST_BODY_LIMIT_MB | Limit for request body size in MB | integer | 20 |
When running Memgraph Lab using Docker, configure the environment variables to
adjust settings. Use the Docker run
command as follows to set these variables:
docker run -d -p 3000:3000 --name lab -e QUERY_MAX_LEN=10000 -e MODULE_NAME_MAX_LEN=2500 memgraph/lab
For Docker Compose, define the same environment variables within the
environment
section of your service configuration in the docker-compose.yml
file:
environment:
- QUERY_MAX_LEN=10000
- MODULE_NAME_MAX_LEN=2500