A Quick Start Guide For MariaDBby@grobbert
329 reads
329 reads

A Quick Start Guide For MariaDB

by Rob HedgpethOctober 27th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Get started with MariaDB in three steps using the official MariaDB docker container.

Company Mentioned

Mention Thumbnail
featured image - A Quick Start Guide For MariaDB
Rob Hedgpeth HackerNoon profile picture

OK, we all know that there are a ton of database options out there these days. Relational (SQL), NoSQL, Distributed SQL (NewSQL). And that’s really just the tip of the iceberg. Choosing a new database is likely one of the most important architectural decisions that go into creating or integrating into a new solution or application.

The reasons for choosing a database can be everything from extremely simple to pretty damn complex, but, ultimately, it all boils down to the type of data workload you’re looking to handle. But that’s not something I’m going to get into, because that’s the kind of research you can certainly go off and do on your own.

Instead, in this article, I want to focus on the quickest way you can go from nothing to having a local instance of a MariaDB database up, running and ready to use so you can start checking things out, using a Docker container, for yourself.

OK, let’s get into it.

Step 1 - Install Docker

Now, unless you’ve been living under a rock for the past several years I'm willing to bet you’ve at least heard of Docker, or, at the very least, the concept of containerization. And, if not, no biggie check this out if you’re curious.

Either way, the good news is that using Docker on your local machine is incredibly easy. Just download and install Docker Desktop.

Step 2 - Start a MariaDB Docker Container

Once you’ve successfully installed Docker on your machine, you’re ready to pull the MariaDB image and spin up a container (which will contain a MariaDB database instance).

For this, you’re going to use the Official MariaDB Docker Image hosted at

Open up a new terminal window and execute the following command.

$ docker run -p --name mdb -e MARIADB_ROOT_PASSWORD=Password123! -d mariadb:latest

The previous statement will pull down the latest version of the Official MariaDB image and spin up a new container on localhost (, exposing port 3306 and allow you to connect using the root user with password Password123!.

Hint: I guess this is something like Step 2-b, but you can confirm that the docker run command has successfully pulled the MariaDB Image and spun up a container by executing docker ps, which will show you all of the containers currently running.

Step 3 - Connect to MariaDB

Lastly, you don’t need to install anything else to start using MariaDB. While you certainly can use other types of clients or tools to connect to and communicate with a MariaDB database, for this brief walkthrough you don't have to worry about any of that. Everything you need you already have. Just use the mariadb command-line client that’s included within the MariaDB Docker container.

Execute the following to connect to MariaDB using the command-line client.

$ docker exec -it mdb mariadb --user root -p Password123!

Which should result in something like the following:

Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.6.3-MariaDB-1:10.6.3+maria~focal binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

And that’s it! That’s all you need to connect to and start using (querying) MariaDB.

Happy coding, friends!

First Published here