# Install Memgraph on Debian

Install and run Memgraph on Debian 12 or Debian 13.

> **Warning**
>
> Newer versions of Memgraph might not be backward
> compatible with older versions and you might not be able to load storage
> snapshots between different versions. In that case, please contact the Memgraph
> team and we'll help with the migration as much as possible.

## Installation guide

### Download Memgraph Debian Package

Downloaded the latest Memgraph Debian Package from the [Memgraph Download Hub](https://memgraph.com/download/).

You can also use [direct download
links](https://memgraph.com/docs/getting-started/install-memgraph/direct-download-links) to get the
latest Memgraph packages. 

For example, for Debian 12:

```bash
sudo wget https://download.memgraph.com/memgraph/v3.13.0/x86_64-deb/memgraph_3.13.0-1_amd64.deb
```

> **Note**
>
> For the latest version of Memgraph, replace the version in the download command
> with the one from the [direct download
> links](https://memgraph.com/docs/getting-started/install-memgraph/direct-download-links) page.

### Install Memgraph

After downloading Memgraph as a Debian package, install it by running the
following:

```
sudo dpkg -i /path-to/memgraph_<version>.deb
```

> **Info**
>
> Why use sudo?
>
> In order to perform some actions on your operating system like installing new
> software, you may need **superuser** privileges (commonly called **root**).

#### Troubleshooting

**Unable to use `sudo`**

If you encounter the following error:

```
-bash: sudo: command not found
```

Install `sudo` with:

```
apt update -y
apt install sudo -y
```

**Unable to install the Memgraph package with `dpkg`**

While running the following `dpkg` command:

```bash
dpkg -i /path-to/memgraph_<version>.deb
```

you may encounter errors that resemble the following:

```
dpkg: error processing package memgraph (--install): dependency problems -
leaving unconfigured Errors were encountered while processing: memgraph
```

These errors indicate that you don’t have all of the necessary dependencies
installed. Before attempting to resolve these dependency issues, it's
recommended to update your package lists to ensure you have the latest
information about available packages. Run the following command:

```
sudo apt update
```

After updating the package lists, you can install the missing dependencies and
finish the installation of Memgraph by issuing the following command:

```
sudo apt-get install -f
```

This command tells `apt` to fix broken dependencies; it will attempt to correct
a system with broken dependencies in place.

### Verify that Memgraph is running

To verify that Memgraph is running, run the following:

```
sudo journalctl --unit memgraph
```

If successful, you should receive an output similar to the following:

```
You are running Memgraph vX.X.X
```

If the Memgraph database instance is not running, you can start it explicitly:

```
sudo systemctl start memgraph
```

If you want the Memgraph database instance to start automatically on each startup, run the
following command:

```
systemctl enable memgraph
```

You can also check the status of the Memgraph database instance by running:
```
sudo systemctl status memgraph
```

#### Troubleshooting

As of Memgraph 3.13, the package installs the Python libraries used by the
bundled query modules — including [NumPy](https://numpy.org/), [SciPy](https://www.scipy.org/) and [NetworkX](https://networkx.org/) — automatically
during package installation (the machine needs network access at install
time). If that automatic installation was skipped (`MG_SKIP_PYTHON_DEPS=1`) or
failed, Memgraph reports it with a note like this on startup:

```
You are running Memgraph v3.13.0
To get started with Memgraph, visit https://memgr.ph/start
NOTE: Please install networkx, numpy, scipy to be able to use proxied NetworkX algorithms. E.g., CALL nxalg.pagerank(...).
```

In that case, install the missing libraries manually as the `memgraph` user
(they must land in the `memgraph` user's environment, since the embedded
interpreter runs as `memgraph`):

```bash
sudo runuser -l memgraph -c 'python3 -m pip install --user networkx numpy scipy'
```

If you are not interested in working with query modules that depend on these
libraries, you can ignore the warnings.

If you run into any troubles while installing Memgraph, contact us on
[Discord](https://discord.gg/memgraph).

### Connect to the database

To [query](https://memgraph.com/docs/querying) the database from the console, you need to install
[`mgconsole`](https://memgraph.com/docs/getting-started/cli). 

You can also connect to the database using one of the [client
libraries](https://memgraph.com/docs/client-libraries) or visual-user interface [Memgraph
Lab](https://memgraph.com/docs/data-visualization).

## Stop Memgraph

To shut down the Memgraph server, issue the following command:

```
sudo systemctl stop memgraph
```

## Start Memgraph

To start the Memgraph server, issue the following command:

```
sudo systemctl start memgraph
```

## Configuration

> **Info**
>
> If you're experiencing issues related to the maximum number of memory map areas,
> you can resolve them by [adjusting the `vm.max_map_count`
> parameter](https://memgraph.com/docs/configuration/system-configuration#increasing-memory-map-areas).

The Memgraph configuration is available in `/etc/memgraph/memgraph.conf`. If the
configuration file is altered, Memgraph needs to be restarted. Check all the
configuration options in the [Configuration
section](https://memgraph.com/docs/database-management/configuration).
