Skip to main content

Connect to Memgraph

Prerequisites

Before you proceed with the guide, make sure that you have either:

  • Installed Memgraph Platform and now have a running database instance and Memgraph Lab is running within the browser on http://localhost:3000, or
  • Installed MemgraphDB and Memgraph Lab and now have a running database instance and the Memgraph Lab desktop application
danger

In order to use Memgraph Lab 2.0 features, you need to run MemgraphDB 2.2.0 or newer. If you are using Memgraph with Docker, expose the port 7444 in order for Memgraph Lab to access log files. For example:

docker run -it -p 7687:7687 -p 7444:7444 -p 3000:3000 memgraph/memgraph-platform

Connecting to Memgraph

Make sure that Memgraph is running and open Memgraph Lab. If you are starting with a fresh database instance, you don't have to change any of the options.

  1. Leave the Username and Password fields empty.
  2. The Host field can be either localhost, 127.0.0.1 or 0.0.0.0.
  3. The Port field should be 7687. Every Memgraph instance is listening on this port by default.
  4. The Encrypted option should be disabled and display SSL Off by default.

If you fail to connect, make sure that your database instance is up and running. If the Host address is wrong, take a look at the Docker note in the installation guide.

Memgraph Lab

Executing 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 (u:User)-[r]->(x) RETURN u, r, x;

Where to next?

To learn more about the Cypher language, visit the Cypher manual or Memgraph Playground for interactive guides. For real-world examples of how to use Memgraph, we strongly suggest going through one of the available Tutorials. Details on what can be stored in Memgraph can be found in the article about Data storage.

Getting help

Visit the Help Center page in case you run into any kind of problem, or you have additional questions.