Running MariaDB on Proxmox offers many benefits for users of Home Assistant and anyone running other data-heavy ap­pli­ca­tions on their own network. In this guide, you’ll learn how to install, configure and manage a MariaDB database inside a Proxmox LXC container.

When is it a good idea to run MariaDB on Proxmox?

MariaDB on Proxmox is a good choice if you want to run database services flexibly in isolated en­vi­ron­ments. Proxmox supports MariaDB in con­tain­ers (LXC) or virtual machines (KVM), letting you address different re­quire­ments sep­a­rate­ly.

What are the pre­req­ui­sites for setup?

Before starting, make sure you have:

  • A running Proxmox host (VE 7 or 8)
  • Access to the Proxmox web interface and shell
  • At least 4 GB of storage and 1 GB of RAM for the LXC
  • Network access for the container (via DHCP or static IP address)
Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flex­i­bil­i­ty with no minimum contract
  • 24/7 expert support included

How to install MariaDB in an LXC container on Proxmox

With Proxmox, you can run MariaDB ef­fi­cient­ly inside an LXC container. The following steps show you how to set up an LXC container and install MariaDB inside it:

Step 1: Run the script

The simplest way to install MariaDB inside an LXC container on Proxmox is to use a community script. Log in to the Proxmox web interface and select your node. Click on Shell and run the following command:

bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/mariadb.sh)"
bash

A security prompt will appear. Press Enter to confirm, then choose either standard or advanced in­stal­la­tion.

Step 2: Configure the in­stal­la­tion

The standard in­stal­la­tion uses these default settings:

  • RAM: 1 GB
  • Storage: 4 GB
  • CPU: 1 vCore
  • Container Type: un­priv­i­leged
  • Network: DHCP

This setup is enough for most cases. In advanced mode, you can configure ad­di­tion­al options such as the Debian version, a root password or a static IP address.

During in­stal­la­tion, you’ll also be asked whether you want to install Adminer. Adminer is a light­weight web front-end for databases. Press Y if you’d like to access MariaDB through your browser later.

When the setup finishes, you’ll see Completed Successfully!. You can then continue with con­fig­u­ra­tion.

Step 3: Edit the con­fig­u­ra­tion file

To let ap­pli­ca­tions like Home Assistant connect to the database, you need to enable remote access.

Open the LXC console in Proxmox and edit the main config file:

nano /etc/mysql/my.cnf
bash

Find the line #port = 3306 and remove the (#) at the beginning to activate it. Save with [CTRL] + [O], press Enter to confirm, and close with [CTRL] + [X].

Step 4: Update the server con­fig­u­ra­tion

Next, edit the server config file inside the container:

nano /etc/mysql/mariadb.conf.d/50-server.cnf
bash

Find this line:

bind-address = 127.0.0.1
bash

Comment it out by adding a # at the beginning:

#bind-address = 127.0.0.1
bash

Save and close the file. Then restart MariaDB:

systemctl restart mariadb
bash

This enables access from the local network.

Step 5: Secure MariaDB

MariaDB includes a built-in security script for basic pro­tec­tion. Run it in the container’s console:

mariadb-secure-installation
bash

You’ll be prompted to:

  • Enter current root password (Press Enter for none):
  • Change the root password? [Y/n] n
  • Remove anonymous users? [Y/n] y
  • Disallow root login remotely? [Y/n] y
  • Remove test database and access to it? [Y/n] y
  • Reload privilege tables now? [Y/n] y

Your MariaDB in­stal­la­tion inside the container is now secured. The database is ready for you to create users and connect services.

Step 6: Create a user and database

Now log in to the MariaDB shell:

/usr/bin/mariadb
bash

Create a new user:

CREATE USER 'homeuser'@'localhost' IDENTIFIED BY 'safepassword';
sql

Grant this user full priv­i­leges on all databases:

GRANT ALL ON *.* TO 'homeuser'@'localhost' WITH GRANT OPTION;
sql

To allow access over the local network, run:

GRANT ALL ON *.* TO 'homeuser'@'192.168.0.%' IDENTIFIED BY 'safepassword' WITH GRANT OPTION;
sql

Create a database of your own, for example, for Home Assistant:

CREATE DATABASE homeassistant;
sql

Apply the changes:

FLUSH PRIVILEGES;
sql

Exit the shell with:

exit
sql

The user account has now been created and can be accessed with the password you set. The database is also ready to accept con­nec­tions from external services.

Step 7: Configure the network and startup order

To ensure MariaDB works reliably with ap­pli­ca­tions like Home Assistant, secure the network con­fig­u­ra­tion and make sure the database container starts before other con­tain­ers.

If you selected DHCP during setup, the MariaDB LXC will be assigned a dynamic IP address, which may change after a restart. To prevent con­nec­tion issues, either set a static IP in the LXC network settings or assign a fixed IP through a DHCP reser­va­tion in your router.

Here’s how to check the current IP address of the container:

ip a
bash

Or view it in the Proxmox interface under Summary -> Network.

Step 8: Define the container’s startup behavior

To ensure Home Assistant can access the database at startup, configure the MariaDB container to start first. You can set the startup order in Proxmox:

  1. Select the MariaDB container.

  2. Click Options.

  3. Double-click Start/Shutdown order.

  4. Enable it and set: “Start order: 1” and “Startup delay: 60 seconds”.

Repeat the process for the Home Assistant container. For example, by setting “Start order 2” and “Startup delay 10 seconds”.

Step 9: Connect Home Assistant to MariaDB

Once the database is ready and has a fixed IP address, configure Home Assistant to use MariaDB instead of SQLite.

Open configuration.yaml in Home Assistant, for example using the File Editor add-on or Visual Studio Code:

recorder:
    db_url: mysql://homeuser:safepassword@192.168.0.45:3306/homeassistant?charset=utf8mb4
yaml

Replace the username, password, IP address and database name with your own values. Make sure MariaDB starts before Home Assistant.

Restart Home Assistant. If every­thing is set up correctly, new data will be stored in the MariaDB database.

Step 10: Back up MariaDB in Proxmox

Proxmox supports snapshots and container backups, so you can back up the MariaDB LXC container at any time — either manually or on a schedule:

  1. Select your MariaDB container from the list on the left.

  2. Click Backup at the top.

  3. Choose a storage location (for example, “local”), select a mode (snapshot rec­om­mend­ed), and start the backup.

For automatic backups, you can set up schedules under Dat­a­cen­ter > Backup.

Go to Main Menu