It's no secret that has become a popular database solution for developers over the past decade. Why? Well, one could argue that it's largely because it's open source and relational. So, for developers, that basically means it's free, and we get the gist of it. But that really only begins to scratch the surface. MariaDB What you may not know is that there are two groups actively contributing to MariaDB; Foundation and Corporation. is the custodian of the MariaDB community code and guardian of the MariaDB community. MariaDB Foundation contributes to the community codebase, but also provides superior quality, enterprise grade products that thrusts MariaDB into the forefront of database vendors. MariaDB Corporation even offers and based solutions, but I digress. MariaDB Corporation columnar HTAP With that in mind, I've written this short walkthrough to provide a launchpad for you to get started using MariaDB with and , within a matter of minutes, so you can check things out for yourself. Docker Node.js Requirements Before jumping into code, you're going to need to make sure you have a few things on your machine. MariaDB client (and NPM - Node Package Manager) Node.js Docker Using a MariaDB Docker Container To pull the and spin up a container simply open a terminal window and run the following. MariaDB Server image $ docker run -p 3306:3306 -d --name mariadb -eMARIADB_ROOT_PASSWORD=Password123! mariadb/server:10.4 The previous command will spin up a MariaDB Server container that you can connect to and communicate with using the MariaDB client. : While you can certainly use a variety of other SQL clients, for the sake of keeping things simple and uniform, I've only included samples using the official MariaDB client. Note Connect to your MariaDB instance by executing the following command in a terminal window. $ mariadb --host 127.0.0.1 -P 3306 --user root -pPassword123! You should see something like the following, which means you've successfully connected to the MariaDB instance! Next, create a new database. demo; CREATE DATABASE Then create a new table. demo.people ( ( )); CREATE TABLE name VARCHAR 50 Finally, insert a couple records. demo.people ( ), ( ), ( ), ( ); INSERT INTO VALUES 'rob' 'tracy' 'sam' 'duke' Connecting to MariaDB with Node.js Now that you've downloaded, installed, and stood up a MariaDB database, you're ready to put it to use within a new Node.js app. To start, pick a new directory, and create a new Javascript file to be used as the main . For simplicity, I used " ". entry point for the Node server server.js Then, within a terminal that the directory location, execute the following. $ npm init Feel free to fill out all of the prompts, or you can just hit the enter key through all of the options. Either way, you'll end up with a file being generated next to package.json server.js. : You now have a runnable Node app, albeit a pretty uninteresting one. So, let's continue to spice it up! Note Install the package which will be used as a lightweight web framework by the Node app. Express $ npm install express Install the , which will be used to connect to and communicate with your MariaDB instance. MariaDB Node.js connector $ npm install mariadb Now it's time to add code to connect to MariaDB. To do this first create a new (reusable) file called module db.js . The module will use the MariaDB Node.js connector that will enable your app to connect to and communicate with MariaDB. db Then you'll paste the following code into it and save. mariadb = ( ); pool = mariadb.createPool({ : , : , : , : }); .exports={ : { ( { pool.getConnection().then( { resolve(connection); }).catch( { reject(error); }); }); } } // import mariadb var require 'mariadb' // create a new connection pool const host "127.0.0.1" user "root" password "Password123!" database "demo" // expose the ability to create new connections module getConnection ( ) function return new Promise ( ) function resolve,reject ( ) function connection ( ) function error You probably won't want to just slap all the sensitive connection information directly into your connection module. This has been done for demo purposes only. Instead, you may consider using something like to handle sensitive environmental data. Tip: dotenv The final development step is to create an Express endpoint that uses the MariaDB Node.js connector (via ). db.js Open , paste the following code into it, and save. server.js express = ( ) pool = ( ) app = express() port = app.get( , (req, res) => { conn; { conn = pool.getConnection(); query = ; rows = conn.query(query); res.send(rows); } (err) { err; } { (conn) conn.release(); } }); app.listen(port, () => .log( )); const require 'express' const require './db' const const 8080 // expose an endpoint "people" '/people' async let try // establish a connection to MariaDB await // create a new query var "select * from people" // execute the query and set the result to a new variable var await // return the results catch throw finally if return console `Listening on port ` ${port} Finally, run the node application. $ npm start Testing it out Once the Node project has been started, you can test it out by executing a request. This can be done through a variety of techniques. For instance, consider executing the following command: curl $ curl http://localhost:8080/people Which yields the following JSON response payload: [{ : },{ : },{ : },{ : }] "name" "rob" "name" "tracy" "name" "duke" "name" "sam" Also, if you'd like to review the Node.js project in its entirety, I've pushed the complete code to . this repository Just the beginning Hopefully this short walkthrough has helped you get started using MariaDB with Node.js. And, yea, this was a very simple example, but it only gets more exciting from here! I highly recommend that you check out all of what MariaDB has to offer and how you can use a truly innovative database to create modern applications. Previously published at https://dev.to/probablyrealrob/getting-started-with-mariadb-using-docker-and-node-js-3djg