# Install Memgraph on Linux

Install Memgraph natively on Linux from a DEB or RPM package and run it as a
systemd service. Since Memgraph 3.13, there is one DEB package and one RPM
package per architecture (x86_64 and ARM64), not one per distribution. They
run on any Linux distribution with glibc 2.31 or newer.

| Distribution family | Package |
|---|---|
| Debian, Ubuntu and other distributions that use `apt` | DEB |
| Red Hat Enterprise Linux, CentOS, Rocky Linux, Fedora and other distributions that use `dnf` | RPM |

To check your glibc version, run:

```bash
ldd --version
```

The packages also need Python 3.10 or newer on the host. On
distributions whose default `python3` is older, such as CentOS 9, the package
installs and uses a newer Python interpreter.

To install on Windows, see [Install Memgraph on Windows with
WSL](https://memgraph.com/docs/getting-started/install-memgraph/wsl). To run Memgraph in a container,
see [Docker](https://memgraph.com/docs/getting-started/install-memgraph/docker).

> **Warning**
>
> Storage snapshots from one Memgraph version might not load in another. Before
> you install a newer version over an existing one, follow
> [Upgrades](https://memgraph.com/docs/database-management/upgrades).

## Install the DEB package on Debian or Ubuntu

Download the DEB package, then install it with `apt`.

### Download the DEB package

Download the package from the [Memgraph Download
Hub](https://memgraph.com/download/) or with a link from [direct download
links](https://memgraph.com/docs/getting-started/install-memgraph/direct-download-links). For example,
the x86_64 package:

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

For the ARM64 package, the system allocator build or a newer version, take the
link from [direct download
links](https://memgraph.com/docs/getting-started/install-memgraph/direct-download-links) and use its
file name in the next step.

### Install the DEB package

Install the package with `apt`, which also installs its dependencies:

```bash
sudo apt install ./memgraph_3.14.0-1_amd64.deb
```

If `sudo` isn't installed, see [sudo is not installed on
Debian](#sudo-is-not-installed-on-debian).

When the package is installed, [configure the system](#configure-the-system).

## Install the RPM package on CentOS, Fedora, Rocky Linux or Red Hat

Download the RPM package, then install it with `dnf`.

### Download the RPM package

Download the package from the [Memgraph Download
Hub](https://memgraph.com/download/) or with a link from [direct download
links](https://memgraph.com/docs/getting-started/install-memgraph/direct-download-links). For example,
the x86_64 package:

```bash
wget https://download.memgraph.com/memgraph/v3.14.0/x86_64-rpm/memgraph-3.14.0_1-1.x86_64.rpm
```

For the ARM64 (aarch64) package, the system allocator build or a newer version,
take the link from [direct download
links](https://memgraph.com/docs/getting-started/install-memgraph/direct-download-links) and use its
file name in the next step.

### Install the RPM package

Install the package with `dnf`:

```bash
sudo dnf install -y ./memgraph-3.14.0_1-1.x86_64.rpm
```

On Red Hat Enterprise Linux, SELinux can block Memgraph's access to system
resources. See [SELinux blocks Memgraph](#selinux-blocks-memgraph).

When the package is installed, [configure the system](#configure-the-system).

## Configure the system

The default limits on most Linux distributions are too low for Memgraph. Check
two of them before you load data:

- **Open files (`nofile`)**: Memgraph uses a file descriptor for each client
  connection and for its storage files. The packaged systemd service sets
  `LimitNOFILE=1048576`. If you run Memgraph without systemd, raise the limit
  yourself, as [Handle numerous open files
  simultaneously](https://memgraph.com/docs/database-management/system-configuration#handle-numerous-open-files-simultaneously)
  describes.
- **Memory map areas (`vm.max_map_count`)**: large workloads can run out of
  them. [Increase the `vm.max_map_count`
  parameter](https://memgraph.com/docs/database-management/system-configuration#increasing-memory-map-areas)
  to the recommended value for your machine's memory.

For the other settings, see [System
configuration](https://memgraph.com/docs/database-management/system-configuration).

## Start Memgraph

Start Memgraph as a service. If it's already running, the command does
nothing:

```bash
sudo systemctl start memgraph
```

To check that Memgraph is running, read its log:

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

The log contains a line like this:

```plaintext copy=false
You are running Memgraph vX.X.X
```

To check the state of the service:

```bash
sudo systemctl status memgraph
```

To start Memgraph automatically when the machine boots:

```bash
sudo systemctl enable memgraph
```

On a system without systemd, run Memgraph as the `memgraph` user:

```bash
sudo -u memgraph /usr/lib/memgraph/memgraph
```

## Connect to Memgraph

To [run queries](https://memgraph.com/docs/querying) from the terminal, install
[`mgconsole`](https://memgraph.com/docs/getting-started/cli). You can also connect with one of the
[client libraries](https://memgraph.com/docs/client-libraries) or with [Memgraph Lab](https://memgraph.com/docs/memgraph-lab), the
visual user interface.

## Configure Memgraph

The configuration file is `/etc/memgraph/memgraph.conf`. For all options, see
[Configuration](https://memgraph.com/docs/database-management/configuration). Memgraph reads the file on
startup, so restart it after you change the file:

```bash
sudo systemctl restart memgraph
```

## Stop Memgraph

```bash
sudo systemctl stop memgraph
```

## Troubleshooting

The problems below can come up during or after installation. If yours isn't
listed, ask on [Discord](https://discord.gg/memgraph).

### sudo is not installed on Debian

If Debian reports the following error:

```plaintext copy=false
-bash: sudo: command not found
```

install `sudo` as the root user:

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

### Python libraries for query modules are missing

Since Memgraph 3.13, the package installs the Python libraries that the bundled
query modules use, including [NumPy](https://numpy.org/),
[SciPy](https://www.scipy.org/) and [NetworkX](https://networkx.org/), during
installation. The machine needs network access at install time.

If that step was skipped (`MG_SKIP_PYTHON_DEPS=1`) or failed, Memgraph prints a
note like this on startup:

```plaintext copy=false
You are running Memgraph v3.14.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(...).
```

Install the libraries as the `memgraph` user, because Memgraph's embedded
Python interpreter runs as that user and only sees its environment:

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

If you don't use the query modules that need these libraries, you can ignore
the note.

### SELinux blocks Memgraph

Red Hat Enterprise Linux uses SELinux (Security-Enhanced Linux) to enforce
mandatory access control: each program can reach only the resources its policy
allows. In a [high
availability](https://memgraph.com/docs/database-management/clustering/high-availability) deployment,
check the SELinux policies if the instances can't see each other. Even with the
firewall open, you might need to disable SELinux, as the [networking
configuration](https://memgraph.com/docs/deployment/best-practices#networking-configuration) best
practices describe.
