Install MariaDB on a Mac

Here’s how to install MariaDB on a Mac via the Homebrew package manager.

Install Homebrew

First, let’s install Xcode and Homebrew. Feel free to skip this step if you’ve already got Homebrew installed.

To install these prerequisites, open a Terminal window and run the following commands.

Install Xcode:

xcode-select --install

Install Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

That’s it. Xcode and Homebrew should be installed once those commands have been run.

But before we move on, here’s how to check Homebrew:

brew doctor

Follow any prompts to fix any problems that may have been encountered.

While we’re at it, here’s how to update Homebrew:

brew update

If you’re already up to date, you’ll get a message to that effect.

Install MariaDB

Now that Homebrew is installed, let’s go ahead and install MariaDB.

First, let’s check the MariaDB version in the Homebrew repo:

brew info mariadb

That will output a bunch of stuff, including the MariaDB version in the repo.

Now here’s the part that actually installs MariaDB:

brew install mariadb

If you have a previous version of MariaDB, follow the prompts to upgrade to the latest version.

Start MariaDB

Now that we’ve installed MariaDB, let’s start it:

mysql.server start

To auto-start MariaDB Server, we can use Homebrew’s services functionality, which configures auto-start with the launchctl utility from launchd:

brew services start mariadb

Connect to MariaDB

Once MariaDB has started, we can connect to it:

mariadb

Once connected, you should see something like this:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.9-MariaDB Homebrew

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)]> 

Here’s an example of a quick command you can use to see a list of databases:

show databases;

Result:

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.001 sec)