How to install MariaDB on Proxmox
Running MariaDB on Proxmox offers many benefits for users of Home Assistant and anyone running other data-heavy applications 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 environments. Proxmox supports MariaDB in containers (LXC) or virtual machines (KVM), letting you address different requirements separately.
What are the prerequisites 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)
- Cost-effective vCPUs and powerful dedicated cores
- Flexibility 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 efficiently 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)"bashA security prompt will appear. Press Enter to confirm, then choose either standard or advanced installation.
Step 2: Configure the installation
The standard installation uses these default settings:
- RAM: 1 GB
- Storage: 4 GB
- CPU: 1 vCore
- Container Type: unprivileged
- Network: DHCP
This setup is enough for most cases. In advanced mode, you can configure additional options such as the Debian version, a root password or a static IP address.
During installation, you’ll also be asked whether you want to install Adminer. Adminer is a lightweight 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 configuration.
Step 3: Edit the configuration file
To let applications 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.cnfbashFind 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 configuration
Next, edit the server config file inside the container:
nano /etc/mysql/mariadb.conf.d/50-server.cnfbashFind this line:
bind-address = 127.0.0.1bashComment it out by adding a # at the beginning:
#bind-address = 127.0.0.1bashSave and close the file. Then restart MariaDB:
systemctl restart mariadbbashThis enables access from the local network.
Step 5: Secure MariaDB
MariaDB includes a built-in security setup script for basic protection. Run it in the container’s console:
mariadb-secure-installationbashYou’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 installation 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/mariadbbashCreate a new user:
CREATE USER 'homeuser'@'localhost' IDENTIFIED BY 'safepassword';sqlGrant this user full privileges on all databases:
GRANT ALL ON *.* TO 'homeuser'@'localhost' WITH GRANT OPTION;sqlTo allow access over the local network, run:
GRANT ALL ON *.* TO 'homeuser'@'192.168.0.%' IDENTIFIED BY 'safepassword' WITH GRANT OPTION;sqlCreate a database of your own, for example, for Home Assistant:
CREATE DATABASE homeassistant;sqlApply the changes:
FLUSH PRIVILEGES;sqlExit the shell with:
exitsqlThe user account has now been created and can be accessed with the password you set. The database is also ready to accept connections from external services.
Step 7: Configure the network and start-up order
To ensure MariaDB works reliably with applications like Home Assistant, secure the network configuration and make sure the database container starts before other containers.
If you selected DHCP during setup, the MariaDB LXC will be assigned a dynamic IP address, which may change after a restart. To prevent connection issues, either set a static IP in the LXC network settings or assign a fixed IP through a DHCP reservation in your router.
Here’s how to check the current IP address of the container:
ip abashOr view it in the Proxmox interface under Summary -> Network.
Step 8: Define the container’s start-up behaviour
To ensure Home Assistant can access the database at start-up, configure the MariaDB container to start first. You can set the start-up order in Proxmox:
-
Select the MariaDB container.
-
Click Options.
-
Double-click Start/Shutdown order.
-
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=utf8mb4yamlReplace the username, password, IP address and database name with your own values. Make sure MariaDB starts before Home Assistant.
Restart Home Assistant. If everything 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 scheduled basis:
-
Select your MariaDB container from the list on the left.
-
Click Backup at the top.
-
Choose a storage location (for example, ‘local’), select a mode (snapshot recommended), and start the backup.
For automatic backups, you can set up schedules under Datacenter > Backup.

