First steps with Memgraph
In this tutorial, you will learn how to install Memgraph Platform, connect to it using Memgraph Lab and run your first query.
A tutorial on this topic is also available as a video on Memgraph's YouTube channel:
Prerequisites
Memgraph Platform can be installed only with Docker. Instructions on how to install Docker can be found on the official Docker website (opens in a new tab).
Install Memgraph Platform
First, you need to download and install Memgraph Platform. Open a terminal on your computer and run the following command:
docker run -p 7687:7687 -p 7444:7444 -p 3000:3000 --name memgraph memgraph/memgraph-platform
Once the installation is done, you will see a message similar to this one:
2023-09-11 09:30:31,692 INFO Included extra file "/etc/supervisor/programs/lab.conf" during parsing
2023-09-11 09:30:31,692 INFO Included extra file "/etc/supervisor/programs/memgraph.conf" during parsing
2023-09-11 09:30:31,692 INFO Set uid to user 0 succeeded
2023-09-11 09:30:31,695 INFO supervisord started with pid 1
2023-09-11 09:30:32,697 INFO spawned: 'memgraph' with pid 7
2023-09-11 09:30:32,698 INFO spawned: 'lab' with pid 8
You are running Memgraph v2.10.1
To get started with Memgraph, visit https://memgr.ph/start
That means that you have installed Memgraph Platform and that you have Memgraph up and running.
Connect to Memgraph Lab
Since you've installed and started Memgraph using the Memgraph Platform,
Memgraph Lab is already running. Open your web browser and go to
localhost:3000
(opens in a new tab). When the Memgraph Lab loads, click
Connect now.
That's it! You can see the Memgraph Lab Dashboard, so you are ready to head over to the next step.
Migrate your data
As a new user, you'll want to populate your fresh Memgraph installation with data. The method you choose will largely depend on the format of your data. Memgraph supports imports from various formats, such as CSV, JSON and using queries listed in a CYPHERL file. For detailed instructions on migrating your data, refer to the data migration documentation.
If you're just getting started and want a quick setup, Memgraph offers a range of pre-made datasets ideal for testing and learning. We have prepared more than 20 datasets you can use for testing and learning. If you wish to use a demo dataset, go to Datasets section, chose a dataset and Load dataset.
A warning will appear, notifying you that importing a new dataset will overwrite the current data in the database. As a new user, you won't have existing data, but it's crucial to note this for future imports. Confirm the action by clicking Confirm.
Once the import completes, click the X to close the dialog.
Run a query
Now that the data is imported it is time to run your first Cypher query. Go to the Query Execution section in the sidebar, and then copy-and-paste the following code into the Cypher editor.
MATCH (n)-[r]-(m)
RETURN n, r, m;
Click Run query to run the above query that will return all the nodes and relationships in the database and see the result in the Graph results tab.
This an example using one of the preloaded datasets:
If you're transitioning from Neo4j to Memgraph, adapting your existing Cypher queries is essential. While both platforms use the Cypher query language, there might be platform-specific features that require adjustments. To assist you, we provide a comprehensive documentation to help you adapt and optimize your queries for Memgraph.
Build a new application
If you're developing a new application and want to utilize Cypher queries across different programming languages, check out our guide on interfacing with Memgraph through various client libraries. Memgraph supports a wide array of programming languages including Java, Python, Rust, and Node.js, among others. Each client library is designed to interface with Memgraph and is optimized for graph database communication.
Running advanced algorithms
Memgraph offers a range of procedures tailored to address specific graph problems. Built-in algorithms such as BFS, DSF, Weighted shortest path, and All shortest paths can be executed using their specific clauses.
Memgraph comes with expanded set of algorithms called Memgraph Advanced Graph Extensions (MAGE) library. MAGE is an open-source repository housing graph algorithms, both by the Memgraph team and the community. These are presented as query modules.
One of the advanced algorithms at your disposal is the PageRank algorithm. You can run it with the folowing code:
CALL pagerank.get()
YIELD node, rank;