Get Started with MariaDB in 3 Steps

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 d…


This content originally appeared on DEV Community and was authored by Rob Hedgpeth

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 https://hub.docker.com.

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

$ docker run -p 127.0.0.1:3306:3306  --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 (127.0.0.1), 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 -pPassword123!

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 mariadb.org 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!


This content originally appeared on DEV Community and was authored by Rob Hedgpeth


Print Share Comment Cite Upload Translate Updates
APA

Rob Hedgpeth | Sciencx (2021-10-27T18:28:15+00:00) Get Started with MariaDB in 3 Steps. Retrieved from https://www.scien.cx/2021/10/27/get-started-with-mariadb-in-3-steps/

MLA
" » Get Started with MariaDB in 3 Steps." Rob Hedgpeth | Sciencx - Wednesday October 27, 2021, https://www.scien.cx/2021/10/27/get-started-with-mariadb-in-3-steps/
HARVARD
Rob Hedgpeth | Sciencx Wednesday October 27, 2021 » Get Started with MariaDB in 3 Steps., viewed ,<https://www.scien.cx/2021/10/27/get-started-with-mariadb-in-3-steps/>
VANCOUVER
Rob Hedgpeth | Sciencx - » Get Started with MariaDB in 3 Steps. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/27/get-started-with-mariadb-in-3-steps/
CHICAGO
" » Get Started with MariaDB in 3 Steps." Rob Hedgpeth | Sciencx - Accessed . https://www.scien.cx/2021/10/27/get-started-with-mariadb-in-3-steps/
IEEE
" » Get Started with MariaDB in 3 Steps." Rob Hedgpeth | Sciencx [Online]. Available: https://www.scien.cx/2021/10/27/get-started-with-mariadb-in-3-steps/. [Accessed: ]
rf:citation
» Get Started with MariaDB in 3 Steps | Rob Hedgpeth | Sciencx | https://www.scien.cx/2021/10/27/get-started-with-mariadb-in-3-steps/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.