How to Use Memgraph: The Beginner's Guide (First Install, the First Graph, Cypher Queries, and the In-Memory Lesson)

CodexFuse Team · 2026-11-07T08:55:43.836Z · 18 min read min read

How Do You Use Memgraph?

Learning how to use memgraph starts with one idea: Memgraph is the high-performance, in-memory graph database that stores connected data as nodes and relationships and answers questions with Cypher, the graph query language. You install it with one Docker command, open Memgraph Lab in your browser, load a sample dataset, and run your first Cypher query in minutes. This memgraph tutorial follows the official Memgraph documentation, and every fact in it was checked in November 2026.

A memgraph install starts with the Docker beginner guide on this site, because the fastest first run is one installer command, and the guide below walks the whole arc from that command to your first graph algorithm. CodexFuse offers no Memgraph tool, so this guide teaches the self-hosted database itself, not a hosted shortcut.

  1. Install Memgraph with the one-command installer on Linux or macOS.
  2. Open Memgraph Lab at localhost:3000 and click Connect now.
  3. Load the Capital cities and borders sample dataset.
  4. Run your first Cypher query and read 738 rows.
  5. Run PageRank from MAGE and read the five highest-ranked cities.
  6. Connect from Python with the Neo4j driver and run one query.
  7. Learn the in-memory lesson: snapshots and the write-ahead log keep your data durable.

What Is Memgraph?

Memgraph is a high-performance, in-memory graph database built in C++ that powers real-time AI context, and it serves as the graph engine for GraphRAG, AI memory, and agentic applications. Data lives as a labeled property graph: nodes carry labels and properties, and relationships carry a type, a direction, and optional properties. Memgraph is not Neo4j: it is a separate database that runs most Neo4j Cypher queries, and the comparison section below draws that line once.

The memgraph repository holds 4,653 stars and 297 forks, or 15.67 stars per fork, and it carries 944 open issues, which is 20.3 percent of its star count, or 4.93 stars per open issue. The repository was created on 2020-09-21, so it is 2,238 days old, or 6.13 years, as of this guide, and it holds 5,496 commits across 67 releases and 171 tags. Version 3.14.0 was released on 2026-10-21, which is 17 days before this guide, and the four releases from 3.12.0 to 3.14.0 arrived within 98 days, or about one release every 24.5 days.

The Community Edition is free forever, and it runs under the Business Source License 1.1. BSL 1.1 is not an OSI open-source license, so call Memgraph source-available rather than fully open source. The GitHub API reports the license field as Other, because the repository carries more than one license, while the license file itself names BSL 1.1 and the Memgraph Enterprise License.

The source lives on GitHub, and the GitHub beginner guide on this site walks through the basics if GitHub is new to you.

FactValue
Latest version3.14.0, released 2026-10-21, 17 days before this guide
GitHub stars4,653
GitHub forks297, or 15.67 stars per fork
Open issues944, or 20.3 percent of the star count
Repository ageCreated 2020-09-21, 2,238 days, or 6.13 years
Commits, releases, tags5,496 commits, 67 releases, 171 tags
Release cadenceFour releases in 98 days, about one every 24.5 days
LicenseCommunity BSL 1.1, Enterprise under the Memgraph Enterprise License
Written inC++
Docker Hub pulls2,334,235 for the core image, or 501.7 pulls per star

How Do You Install Memgraph with Docker?

A memgraph docker install starts with the MAGE image, because that image bundles the database with the graph algorithms library. The one-command installer is the fastest path on Linux and macOS, and the direct Docker run command suits readers who want to see every flag. No commands in this guide were executed in a live testbed; the steps follow the official documentation as fetched on 2026-11-07.

curl -sSf "https://install.memgraph.com" | sh
iwr https://install.memgraph.com/windows -useb | iex

The installer downloads a Docker Compose file into a memgraph-platform folder in your home directory and starts two containers: memgraph-mage on ports 7687 and 7444, and memgraph-lab on port 3000. Stop both containers with docker compose stop in that folder, and start them again with docker compose start. The folder name is memgraph-platform, and it holds only the Compose file, not the database image.

docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph-mage
docker exec -it memgraph-mage mgconsole

The direct run starts the database with MAGE and opens mgconsole, the command-line client for Cypher queries, inside the running container. The core image memgraph/memgraph holds the database plus mgconsole, while memgraph/lab holds only the Lab interface. The memgraph-platform image is stale: its last update was 2024-02-16, or 995 days before this guide, so old guides that install it teach a retired path.

RouteCommandBest for
One-command installercurl -sSf "https://install.memgraph.com" | shFirst install on Linux or macOS
Windows installeriwr https://install.memgraph.com/windows -useb | iexFirst install on Windows
Docker run, MAGE imagedocker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph-mageReaders who want to see every flag
Core image onlydocker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraphDatabase without the algorithms library
Lab alonedocker run -d -p 3000:3000 --name lab memgraph/labVisual interface against an existing database
Native packagesDebian, Ubuntu, RHEL, Fedora, or CentOS packagesServers without Docker

The installer and the images both come from the public Memgraph repositories, and the Git beginner guide on this site covers cloning a repository if Git is new to you.

How Do You Open Memgraph Lab?

A memgraph lab session starts at localhost:3000, where the Quick connect screen waits with a Connect now button. Click it, and Lab connects to the database on port 7687 with no username or password. A default Memgraph runs with no authentication, so set up authentication before you expose Memgraph beyond your own machine, because anyone who can reach port 7687 can run queries.

Lab gives you a Cypher editor, a graph visualization, schema exploration, sample datasets, and query history. Run Lab alone with docker run -d -p 3000:3000 --name lab memgraph/lab, or download the desktop app from the Memgraph site. Lab runs on port 3000, not 3030, and one well-known guide prints the wrong port.

PortUsed for
7687Bolt, the port clients use to connect and run queries
7444Log stream to Memgraph Lab for real-time monitoring
3000Memgraph Lab web interface at localhost:3000
8000Memgraph MCP server for coding agents

How Do You Load Your First Graph?

Open the Datasets section in the Lab sidebar, find Capital cities and borders, and click Load dataset. The dataset holds capital cities connected by their borders, and it is the sample the official quickstart uses. Loading takes seconds, and the graph is ready to query as soon as the button finishes.

MATCH (n)-[r]-(m) RETURN n, r, m;
CREATE (:Developer {name: 'Ana'})-[:USES]->(:Database {name: 'Memgraph'});
MATCH (d:Developer)-[:USES]->(db:Database) RETURN d.name AS developer, db.name AS database;
CALL pagerank.get() YIELD node, rank RETURN node.name AS city, rank ORDER BY rank DESC LIMIT 5;

Paste MATCH (n)-[r]-(m) RETURN n, r, m; into the Cypher editor and click Run query. It returns every pair of connected nodes and the relationship between them, 738 rows on this dataset, and the Graph results tab draws the cities on a world map connected by their borders.

What Are the First Cypher Queries to Learn?

A memgraph cypher query starts with MATCH for reads and CREATE for writes, and the two verbs below cover most beginner work. Memgraph implements openCypher, the open standard of Cypher, and it is compatible with Neo4j for most queries. The query language is the same one Neo4j users already know, so Cypher skills transfer in both directions.

VerbWhat it doesExample
CREATECreates nodes and relationshipsCREATE (:Developer {name: 'Ana'})
MATCH ... RETURNFinds a pattern and returns itMATCH (n)-[r]-(m) RETURN n, r, m
SET and REMOVEChanges or removes propertiesSET n.name = 'Ana'
DELETEDeletes a node or relationshipDELETE r
DETACH DELETEDeletes a node with its relationshipsDETACH DELETE n
AggregationsCounts, averages, and collects valuescount(), avg(), collect()
Variable-length pathsFollows one to three hops in one pattern[:KNOWS*1..3]

The CREATE example above makes one Developer node called Ana, one Database node called Memgraph, and one USES relationship between them, then reads the pair back as one row: Ana and Memgraph. Variable-length paths such as [:KNOWS*1..3] follow one to three hops of KNOWS in a single pattern, which is how graph queries express friends of friends without joins.

A few Cypher differences from Neo4j exist, and a practitioner summary of the official differences page lists relationship uniqueness, existence, and type constraints as unsupported, plus indexes that are not created automatically. Check the official differences page before you rely on a Neo4j-only feature, because a few constraint and index behaviors differ.

How Do You Run Your First Graph Algorithm?

MAGE is the open-source library of graph algorithms that ships inside the memgraph-mage image, and it exposes each algorithm as a Cypher procedure you CALL. The library holds more than 40 algorithms, including PageRank, community detection, and node2vec. The MAGE image holds 964,051 Docker Hub pulls, or 41.3 percent of the core image pulls, which shows how many installs choose the algorithms bundle.

Run CALL pagerank.get() YIELD node, rank RETURN node.name AS city, rank ORDER BY rank DESC LIMIT 5; and the Data results tab shows the five highest-ranked cities. This guide does not repeat the rank values from the official quickstart, because the fetched copy shows two identical adjacent values that look like a transcription error.

AlgorithmWhat it answers
PageRankWhich nodes matter most in the network
Community detectionWhich nodes cluster together
node2vecWhich nodes behave alike, as embeddings
GNN link predictionWhich missing links probably exist
Temporal graph networksHow the graph changes over time
EmbeddingsWhich nodes sit near each other in vector space

How Does Memgraph Connect to Python?

A memgraph python connection starts with the Neo4j driver, because the current Python docs lead with the Neo4j Python client version 5 and above. Memgraph and Neo4j both speak Bolt and Cypher, so the same client works with both. The driver connects to bolt://localhost:7687, and no credentials are needed on a default install.

from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://localhost:7687")
with driver.session() as session:
    result = session.run("MATCH (n) RETURN count(n) AS nodes")
    print(result.single()["nodes"])

The snippet opens a Bolt session, counts every node in the database, and prints the number. The count query is the fastest health check after a first install, because it proves the driver, the port, and the database all work at once. If the count returns zero, the database is running but empty, and the dataset step above is the fix.

GQLAlchemy is the alternative Python path: pip install gqlalchemy gives you an object-graph mapper and a Match query builder for Memgraph. The gqlalchemy repository holds 302 stars and 51 forks, or 6.5 percent of the core repository stars and 17.2 percent of its forks, and its last push was 2026-09-10, or 58 days before this guide, so it is still maintained. The docs lead with the Neo4j driver and present GQLAlchemy second, and this guide follows that order.

The best-known Python guide is the Memgraph Python and Jupyter Notebooks blog post from 2021-11-09, which is 1,824 days old, or 4.99 years, and its install command uses the memgraph-platform image. Do not copy that command, because the image is 995 days stale, and its dev.to mirror from 2023-03-23 is 1,325 days old, or 3.63 years. A second independent guide on Towards Data Science is about 655 days old, or 1.79 years, and it prints the wrong Lab port.

What Is the In-Memory Lesson?

Memgraph keeps your graph in RAM, and that is where its speed comes from: traversals read memory instead of disk, so multi-hop queries stay fast as the graph grows. The lesson is that in-memory does not mean temporary, because Memgraph pairs RAM with a write-ahead log and periodic snapshots, so data survives a restart. Redis is the other famous in-memory store, and the Redis beginner guide on this site covers its key-value model, which is a useful contrast to a graph model.

The default storage mode is IN_MEMORY_TRANSACTIONAL, and every change creates a Delta object that is recorded in the write-ahead log before it is written to the database. Snapshots capture the full database state every 300 seconds by default, and only the 3 most recent snapshots are kept, so the default snapshot history covers about 15 minutes. On startup, Memgraph recovers from the latest snapshot and replays the newer log entries.

A snapshot runs 12 times per hour, or 288 times per day, and you can take one on demand with CREATE SNAPSHOT; or on exit with the snapshot-on-exit flag. Snapshots are not compatible between Memgraph versions, so keep the version in mind when you move snapshot files between installs. The write-ahead log is enabled by default, and log-only operation is not possible, because snapshots must stay enabled too.

Storage modeHow it worksTrade-off
IN_MEMORY_TRANSACTIONALData in RAM, WAL plus snapshots, full ACIDDefault, fastest, needs enough RAM
IN_MEMORY_ANALYTICALData in RAM, no deltas, no WAL, manual snapshots onlyFaster imports and analysis, no ACID
ON_DISK_TRANSACTIONALRocksDB-backed storage, full ACIDLower memory cost, slower than RAM

The three storage modes trade speed against cost, and the default is the right choice for a first install. The on-disk mode is listed by the vendor as a supported mode, while independent sources call it experimental, so treat its maturity as attributed, not vendor fact. The analytical mode suits bulk loads and read-only analysis, and you switch to it only on an empty database.

How Much RAM Does Memgraph Need?

The minimum hardware is 1 GB of RAM, 1 GB of disk, and 1 vCPU, and that minimum runs a small test graph on your laptop. The recommended hardware is at least 16 GB of ECC RAM, disk at least 3 times the RAM, and at least 8 vCPUs or 4 physical cores. Host Python 3.10 or newer is required for Python query modules, and native Linux packages need glibc 2.31 or newer.

Data sizeRAM neededDisk needed
Test graph, under 1 GB1 GB minimum1 GB minimum
8 GB of data16 GB48 GB at 3 times RAM
100 GB of data200 GB600 GB at 3 times RAM
Recommended serverAt least 16 GB ECC RAMAt least 48 GB on NVMe SSD

The vendor sizing rule is simple: plan about twice as much RAM as data, so 8 GB of data needs at least 16 GB of RAM, and 100 GB of data needs 200 GB of RAM and 200 GB of disk. A VPS with enough RAM suits a small self-hosted install, and the what is VPS hosting guide on this site explains the hosting side. The Lab image holds 441,554 Docker Hub pulls, or 18.9 percent of the core image pulls, and the core image was registered on 2021-02-18, which is 2,088 days before this guide, or 5.72 years.

Memgraph vs Neo4j: What Is Different?

Memgraph vs neo4j is the comparison most readers ask about, and the short answer is that Memgraph is the in-memory, C++ alternative that runs most Neo4j Cypher. The vendor comparison page was published on 2023-05-15, which is 1,272 days before this guide, or 3.48 years, so treat its details as the vendor position of that date. The vendor table lists Memgraph's first release as 2017, while an independent guide says the first production release came in 2018, so this guide states no release year as settled fact.

AreaNeo4jMemgraph
First release2007, per the vendor table2017, per the vendor table
Written inJavaC++
LicenseAGPLv3 or commercialBSL, Apache 2.0 for some parts, or commercial
StorageOn-disk firstIn-memory first
Data modelLabeled property graphLabeled property graph
Query languageCypherCypher, compatible for most queries
StreamingKafka and Redpanda through a Kafka Connect pluginNative Kafka, Redpanda, and Pulsar connectors
Data science libraryGraph Data Science libraryMAGE, with more than 40 algorithms
Custom proceduresJavaPython, C, C++, and Rust
DriversNeo4j driversMost Neo4j drivers also work with Memgraph

Memgraph claims its engine is faster than Neo4j, and secondary sources quote different multiples, so this guide states no performance multiple as fact. Performance multiples are vendor claims, not independent facts, and no two secondary sources agree on the number. The vendor verdict is attributed, not independent: Memgraph calls itself the faster choice for real-time data, and calls Neo4j the good choice for Java-oriented developers and static data.

Neo4j is the older, disk-first database with the larger ecosystem, and Memgraph is the newer, memory-first database aimed at real-time work. Pick Neo4j when you want the widest tooling, and pick Memgraph when your queries must stay in memory and answer in real time. Either way, the Cypher you learn on one transfers to the other for most queries.

What Are the Seven Mistakes Beginners Make?

Seven mistakes show up in almost every first install, and each one has a one-line fix. The table below is the fastest review in this guide: read it once before your first deploy, and most first-run trouble disappears.

MistakeFix
Installing the memgraph-platform image from old guidesUse the installer or the memgraph-mage image instead
Opening port 7687 to the internet with no authenticationKeep Memgraph on your own machine until auth is set up
Copying the 2021 Python guide install commandUse the current installer, not the 995-day-stale image
Expecting snapshots to move between versionsRecreate snapshots after every version upgrade
Calling BSL 1.1 an open-source licenseCall it source-available, because the OSI does not recognize BSL
Quoting the 2023 Enterprise price as currentCheck the enterprise page, because no current dollar figure is published
Opening Lab on port 3030 from a popular guideLab runs on port 3000

Sources

The official Memgraph documentation supplied the install commands, the ports, the system requirements, the quickstart steps, and the Python client guidance, all fetched on 2026-11-07. The memgraph repository page and the v3.14.0 release page supplied the star, fork, issue, and release figures, and Docker Hub supplied the pull counts for the core, MAGE, Lab, and platform images. The vendor comparison page, the enterprise page, and the legal page supplied the Neo4j comparison, the trial terms, and the license facts.

Independent guides supplied the freshness check: the Wasql crash course, the Towards Data Science network-analysis guide, the Arm install guide, and the Clint Johnson practitioner post on Neo4j versus Memgraph. The Memgraph Python and Jupyter Notebooks blog post from 2021-11-09 and its dev.to mirror from 2023-03-23 supplied the stale-guide ages, and the vendor snapshots post from 2024-09-25 supplied the persistence background. No Facebook promotion applies to this guide, which is published on the CodexFuse blog only.

All arithmetic in this guide was computed from the fetched figures on 2026-11-07, and the block below shows the working. The release cadence, the star and pull ratios, the RAM sizing, and the snapshot timing all come from that computation, not from any source page.

repo_days = 2238
repo_years = round(repo_days / 365.25, 2)
print(repo_days, repo_years)
print(round(4653 / 297, 2))
print(round(944 / 4653 * 100, 1))
print(round(4653 / 944, 2))
print(round(2334235 / 4653, 1))
print(round(964051 / 2334235 * 100, 1))
print(round(441554 / 2334235 * 100, 1))
print(8 * 2, 100 * 2, 16 * 3, 200 * 3)
print(3600 // 300, 86400 // 300, 3 * 300 // 60)
print(round(302 / 4653 * 100, 1))
print(round(51 / 297 * 100, 1))
print(98 / 4)

Frequently Asked Questions

Is Memgraph free?

The Community Edition is free forever under the Business Source License 1.1, and it is fully functional for self-hosted use. The Enterprise Edition offers a 30-day free trial, and Memgraph Cloud offers a 14-day trial. No current dollar price for Memgraph Enterprise is published, so check the enterprise page for the current terms.

Is Memgraph the same as Neo4j?

No, Memgraph is a separate database written in C++, while Neo4j is written in Java and stores data on disk first. Memgraph runs most Neo4j Cypher queries, because both implement Cypher and speak the Bolt protocol. A few constraint and index behaviors differ, so check the official differences page before you rely on a Neo4j-only feature.

Does Memgraph lose data when it restarts?

No, Memgraph pairs RAM with a write-ahead log and periodic snapshots, so data survives a restart. Snapshots run every 300 seconds by default, and only the 3 most recent snapshots are kept, which covers about 15 minutes of snapshot history. On startup, Memgraph recovers from the latest snapshot and replays the newer log entries.

How do I connect Python to Memgraph?

Install the Neo4j Python driver and connect to bolt://localhost:7687, because the current docs lead with that driver. GQLAlchemy is the alternative path, and pip install gqlalchemy gives you an object-graph mapper and a query builder. Both paths need no credentials on a default install, because the default database runs with no authentication.

How much RAM does Memgraph need?

The minimum is 1 GB of RAM, 1 GB of disk, and 1 vCPU for a small test graph. The vendor rule is about twice as much RAM as data, so 8 GB of data needs 16 GB of RAM, and 100 GB of data needs 200 GB of RAM. The recommended server is at least 16 GB of ECC RAM with disk at least 3 times the RAM.

Featured on Twelve Tools Hunt for Tools Featured on LaunchBuff Launch Llama Tools Launch your MCP Top Web Development Companies in the US - OnToplist.com Designer Listings Listed on SeeWhatNewAI Featured on SubmitMySaas Featured on AI Agents Directory Product Wing SaaS Wheel