Which Database Is Best For Raspberry Pi? (My Top 5)
Many projects on Raspberry Pi require a database system to store various data to use later. Hosting a database can even be a project in itself, with many options are available on Raspberry Pi, and making a choice isn’t always straightforward. In this article, I will introduce the most popular solutions, and explain the pros and cons of each to help you decide.
As a whole, there is no perfect database management system for all use cases on Raspberry Pi. This is a personal choice: each system has pros and cons, so the decision will vary depending on the project goals and the developer’s skills.
As a web developer, I tend to use the same technologies (programming language and database system). It’s not because they are the “best” choices, but rather because I’ll build everything way faster by using what I’m familiar with. Anyway, if you don’t already have your favorites, let’s see what options you should consider.
If you’re looking for inspiration for your next Raspberry Pi project, I’ve put together a list of 75+ ideas with full descriptions, difficulty ratings, and links to tutorials. Whether you’re a beginner or more advanced, there’s something here for you. Grab the list for free here!
MariaDB (MySQL)

MariaDB is a free and open-source fork of MySQL, created when Oracle bought Sun (and so MySQL) a few years ago. It has improved a lot since then, so MariaDB is almost the default choice when installing a new MySQL server.
Even if many other options try to contest the leadership of MySQL in the database hierarchy, it’s still one of the most popular options. I did a poll on my YouTube channel, and almost 70% of my followers still recommend it on Raspberry Pi:

MariaDB is a great choice to store a large amount of data, especially if you need to manage several users with different sets of permissions. It’s particularly used for web projects (with the PHP language in general).
You might also like: Tired of Raspberry Pi OS? Level up with these top-rated systems.
It works well on recent Raspberry Pi models with small to medium databases, but might be a bit too heavy for older ones or the Raspberry Pi Zero.

When you look at Google Trends, MySQL is still the most popular solution, so it will be easy to find documentation, forums, and help when using this database system in your projects.
MariaDB/MySQL uses SQL for queries, which is also the most popular language, so there’s no problem finding resources about it when you try to do complex queries.
You can get answers from real experts in minutes.
Get help with your setup
As a web developer, I’ve mainly worked with MySQL and PHP for years, so it’s generally my default choice when starting new projects. I’m rarely disappointed or stuck with it, so I would recommend it in most situations.
Installation
MariaDB is available in the default repository on Raspberry Pi OS and most other distributions, so installing it should be straightforward. It’s one of the few solutions in this list that works on a client/server mode, which means you have to install a server first.
By the way, you can have a MySQL server on a different Raspberry Pi (or computer) if needed. If your project uses a very limited Raspberry Pi model but can access another device running the MySQL server, it’s fine.
To check if you already have MySQL installed, you can follow this other article I wrote on the topic.
If it’s not (yet) installed, follow these steps to get it on your Raspberry Pi:
Before installing the server, do the system updates with:sudo apt update
sudo apt upgrade
Then install MariaDB with:sudo apt install mariadb-server

But there are some extra steps after that to create the root password and the first user.
I explain everything in this full tutorial on how to use MariaDB on Raspberry Pi.
As MariaDB/MySQL can handle different levels of permissions, it can be a bit complicated for beginners, but you’ll quickly get it by reading my tutorial. I also share a graphical tool you can use to manage your MySQL server, without having to type tons of commands and SQL queries.
Usage
Once the server is installed, the MySQL server can be accessed with almost any language. You may need to install additional packages to use it, but you’ll easily find help for your favorite language.
For example, if you are using PHP to create your web project, you’ll have to install this package to connect to your new MySQL server with it:sudo apt install php-mysql
Once done, you can use all the PHP functions listed on the PHP website.
In Python, you can use PIP to install the MariaDB connector, something like:sudo pip3 install mariadb
There is a great tutorial on the official MariaDB website to get started with MariaDB and Python (link here).
Bonus tip: When I started, the hardest part wasn’t the setup, it was figuring out what to build next. I ended up creating a list of 75+ project ideas with links and difficulty, so it’s easier to just pick something and try it. Grab the list here.
If you want a clearer path than jumping from tutorial to tutorial, my book gives you a step-by-step roadmap to really understand your Raspberry Pi.
Check the book hereTip: Command lines can be a pain to memorize. I put the essential Linux commands on a printable cheat sheet so you don't have to keep googling them. You can grab the PDF here if you want to save some time.
SQLite

SQLite is an interesting alternative to MySQL, especially on Raspberry Pi. This database system is way lighter (hence the name). You need less than 1 MB to install it, while MariaDB requires almost 200 MB of various packages.
SQLite is a server-less database system that is self-contained. It comes with many limitations that might be an issue for bigger projects (single user without authentication, for example), but for small projects at home, it’s often the easiest way to get started.
In short, SQLite is great for small and standalone projects that use a limited amount of data and don’t have any network connection.
Note: TinyDB is another alternative to consider, really close to SQLite. I won’t give a full introduction to it, but basically, it’s even lighter than SQLite. Some features are missing, but you shouldn’t need them most of the time for small Raspberry Pi projects.
Installation
To install SQLite on Raspberry Pi OS (and on any Debian-based distribution), you can simply run this command:sudo apt install sqlite3
From there, you can use the sqlite3 command to create your databases and interact with them.
Here is for example my full log when testing in on my Raspberry Pi:
You might also like: Pi5 vs. Pi4: I tested them, here's the result

As you can see, I just point to the database file after the “sqlite3” command. It will create it if it doesn’t exist yet.
Then you can directly use SQL commands to create a table, insert data and do queries in it.
It can’t be more simple. Obviously, you need to know how to use the SQL language, but everything else is straightforward.
Usage
Similar to MariaDB, you’ll then need to install a connector to access the SQLite database from your project’s code:
- With PHP:
sudo apt install php-sqlite3
Once installed, you can use the SQLite3 functions. - With Python, it should work directly, here is a basic example:

Remember that there is no security, users, and permissions with this solution. It’s great because it’s easy to set up and get started, but don’t use it for larger projects with sensitive data.
MongoDB

MongoDB is very different from the previous options listed in this article. It’s a non-relational database management system, meany the data storage is very flexible. Basically, it’s an association of keys and values, that can be from any type (strings, arrays, objects, etc.).
It doesn’t use the SQL language or any variant of it. It uses MQL (MongoDB Query Language) which is completely different from what you might be used to.
Overall, it’s a decent option when you have no experience with MySQL (some people will argue that it’s easier to start with MongoDB instead of MySQL) and need more flexibility (for example, if your project is not completely defined and may evolve a lot over time).
To be honest, I’m not a big fan of MongoDB. I had many issues with it, in terms of security and basic understanding of how to find what I’m looking for in databases created by other developers. But that’s probably because I know it less than SQL-based solutions.
Installation
Installing MongoDB on Raspberry Pi OS is particularly complex, as it’s not available in the default repository, and they don’t have any compiled package you can download from their website.
The only option is to compile it from sources, as explained in their documentation.
It took me a while and it finally crashed my system, so I can’t really recommend it, but if you want to give it a try, check their documentation. I also found a Mongo for Pi project on GitHub, but I didn’t test it, so I can’t really recommend it either.
The easiest way to get MongoDB on your Pi is to install Ubuntu first. Then you can follow this page on their documentation to add the repository and follow the other configuration steps.
Usage
Once MongoDB is installed and your first database is created, using it on Raspberry Pi is not very different from the previous solutions.
For example, to connect to your Mongo database with Python, you first need to install this library:sudo apt install python3-pymongo
And you can then import “pymongo” in your script and use all these functions.
PostgreSQL

PostgreSQL is one of the most popular databases in enterprise settings. The main difference with MySQL is that PostgreSQL is an object-oriented database, while MySQL is a relational database. PostgreSQL is also recommended for complex queries, large data warehouses, and data analysis.
It has been in a fight with MySQL for a long time. It looks like MySQL/MariaDB is winning, but PostgreSQL is very stable in the trends, so I guess there are still a lot of developers using it:

PostgreSQL doesn’t exactly fit with the traditional Raspberry Pi usage, which is generally for small projects. But if you are used to PostgreSQL, I understand you might be interested in using it on your Raspberry Pi too.
Installation
Like MariaDB, PostgreSQL is available in the default repository on Raspberry Pi OS, so you can install it with:sudo apt install postgresql

Bonus tip: When I started, the hardest part wasn’t the setup, it was figuring out what to build next. I ended up creating a list of 75+ project ideas with links and difficulty, so it’s easier to just pick something and try it. Grab the list here.
You’ll then need to create the first user with:sudo su postgres
createuser $USER -P --interactive
And then use the psql command to connect to your database, and use the SQL language to manage everything:psql
I have a complete tutorial about setting up PostgreSQL on Raspberry Pi here if you need more details.
Usage
PostgreSQL is very popular and works with almost any language.
If you want to use it with Python, the most commonly used library is psycopg2:sudo pip3 install psycopg2
You can then import it into your scripts, and use the class to connect to your database.
Here is a great tutorial to get started with Python and PostgreSQL.
InfluxDB

The last option I want to introduce in this list is InfluxDB, a time series database. Although it stores and queries large amounts of data like any other database, InfluxDB is more optimized for time-stamped data; in other words, when the key index is time.
Time series databases are traditionally used in financial market analysis and industrial automation setups. However, they can also be extremely convenient for system monitoring tasks, DevOps, IoT monitoring, and sensor data monitoring.
Unlike the relational databases we covered earlier, InfluxDB was built as a time series database from the outset, and is therefore optimized for this purpose. InfluxDB also has an edge-optimized version for low-power devices like the Raspberry Pi.
Installation
InfluxDB cannot be installed from the default repo on Raspberry Pi OS. Instead, you’ll need to manually add its repo to install it.
Check this: Make Passive Income with Raspberry Pi
Here’s a quick summary of how to install InfluxDB on Raspberry Pi:
- Add the GPG secure key and repo by pasting this one long command:
curl --silent --location -O https://repos.influxdata.com/influxdata-archive.key
gpg --show-keys --with-fingerprint --with-colons ./influxdata-archive.key 2>&1 \
| grep -q '^fpr:\+24C975CBA61A024EE1B631787C3D57159FC2F927:$' \
&& cat influxdata-archive.key \
| gpg --dearmor \
| sudo tee /etc/apt/keyrings/influxdata-archive.gpg > /dev/null \
&& echo 'deb [signed-by=/etc/apt/keyrings/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' \
| sudo tee /etc/apt/sources.list.d/influxdata.list
- Refresh the repo to see new packages:
sudo apt update - Install the InfluxDB package:
sudo apt install influxdb2 - After it’s installed, you also need to start the InfluxDB service:
sudo systemctl start influxdb

Usage
You can use InfluxDB from either a graphical interface or from the command line.
The graphical interface makes it easier to manage. Just visit the web panel from a browser:http://<IPADDRESS or HOSTNAME>:8086

If you like doing things manually, you can always invoke the command from the command line:influx

I have a complete tutorial about Getting Started With InfluxDB on Raspberry Pi you can follow if you want more details.
Still stuck after following this guide? Drop your question in the RaspberryTips Community — real Pi users answer fast. Post your question here.
Related Questions
Can SQL server run on Raspberry Pi?
SQL Server is the database management system created by Microsoft for Windows servers. They released a version for Linux servers a while ago, but it’s only designed for x86 architectures, meaning it’s incompatible with a Raspberry Pi.
An alternative would be to run Azure SQL Edge in Docker or have another computer running Windows host the server. You can then use ODBC with most languages to connect to the SQL server from your Raspberry Pi.
Overall, Microsoft products (Windows or SQL server) can work but are not optimized for the Raspberry Pi, so I wouldn’t recommend using them for now.
How to view and manage databases on Raspberry Pi?
Each database management system has a set of tools you can use to make your life easier and manage the databases and permissions from a graphical interface. MariaDB/MySQL has PHPMyAdmin, SQLite has DB4S, MongoDB has Compass, etc.
So, even if you’ll need to type a few commands to install them, you’ll most likely use a GUI after that for the daily operations.
Ready to try this for real?
Reading is easy. Doing is different.
Once you start your own setup, things don’t always go as planned. That’s where people lose hours.
Get help right away instead of figuring everything out alone.
- Avoid the usual beginner mistakes
- Get guidance on your setup
- Access step-by-step videos for most projects
