Installing MariaDB on macOS

How to install MariaDB Server on macOS using the Homebrew package manager, including starting the service and securing the installation.

MariaDB Server is available for installation on macOS via the Homebrew package manager. MariaDB Server (together with many client programs and helper tools) is available as a Homebrew "bottle", a precompiled package. If you haven't yet installed Homebrew, see this section.

Installing & Starting MariaDB

Install MariaDB Server:

brew install mariadb

Start MariaDB Server:

mysql.server start

Alternatively, and strongly recommended, automatically start MariaDB Server:

brew services start mariadb

Automatically starting MariaDB server installs a background service on macOS. Make sure to allow adding that background service. See this section for more information.

Connecting to MariaDB Server

After MariaDB Server has started, you can connect to the server using the shell user name (see this section for information on the user):

mariadb

Alternatively, connect as root:

sudo mysql -u root

For graphical clients you can use instead of the mariadb command-line client, see this section.

Upgrading MariaDB

Update Homebrew packages:

Then upgrade MariaDB Server:

Notes & Further Information

Homebrew Installation

Install Homebrew like this:

  1. Open a Terminal (⌘ + Space to open Spotlight, type Terminal).

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

    1. Alternatively, use the package installer (.pkg; at the time of writing this, https://github.com/Homebrew/brew/releases/download/5.0.4/Homebrew-5.0.4.pkg)

  3. Refer to the Homebrew website for more information, particularly to the Homebrew documentation.

MariaDB Configuration

In Homebrew, the configuration file for MariaDB is located at:

  • /usr/local/etc/my.cnf for Intel-based Macs.

  • /opt/homebrew/etc/my.cnf for Apple Silicon Macs (ARM architecture).

MariaDB Information

Find information about the MariaDB version, analytics, and more, using the brew info command:

MariaDB Programs

MariaDB Server (mariadbd), the MariaDB command-line client (mariadb), and many more clients and tools are installed in /opt/homebrew/Cellar/mariadb (for Apple Silicon Macs). Find the location for your machine, as well as the MariaDB programs installed, with these commands:

Terminal User & MariaDB User

To find out which user is used, issue these commands in a shell like Terminal:

macOS Background Service

If you start MariaDB automatically, a macOS background service is added. You can find the MariaDB background service in System Settings > General > Login Items & Extensions. It's named mariadbd-safe.

The toggle switch allows you to turn off the automatic start of MariaDB. This prevents MariaDB Server from automatically starting once you reboot macOS.

To review the resource usage of MariaDB Server, use this command (type q to exit topwhen done):

Graphical Clients

MariaDB doesn't offer graphical clients for working with MariaDB Server, but there are many third-party graphical clients, some of which run on macOS. One of those is Beekeeper Studio, a subscription-based client that has a (not too) limited free version, though.

Assuming a standard Homebrew installation of MariaDB, and assuming you connect to MariaDB Server using the standard shell user, configure Beekeeper Studio like this:

  • Connection type: MariaDB

  • Authentication method: Username/Password

  • Connection mode: Socket

  • Socket path: /tmp/mysql.sock

  • Username: (name of the shell user, without the @localhost suffix)

Once connected to MariaDB Server, you can run queries in Beehive Studio:

The query shown in this screenshot uses a MariaDB sample database called nation which you can use to get familiar with MariaDB. See this section for more information.

MariaDB Sample Database

MariaDB offers a sample database you can use to get familiar with using MariaDB. You can download it here: https://mariadbtutorial.com/wp-content/uploads/2019/10/nation.zip

Unzip nation.zip, then import the database into MariaDB Server, using this command (assuming you downloaded and unzipped the sample database in the Downloads folder):

When done, use that database in the mariadb command-line client, like this:

Alternatively, open the database in a graphical client.

Building MariaDB Server from source

In addition to the "bottled" MariaDB Server package available from Homebrew, you can use Homebrew to build MariaDB from source. This is useful if you want to use a different version of the server or enable some different capabilities that are not included in the bottle package.

Two components not included in the bottle package are the CONNECT and OQGRAPH engines, because they have non-standard dependencies. To build MariaDB Server with these engines, you must first install boost and judy. Follow these steps to install the dependencies and build the server:

You can also use Homebrew to build and install a pre-release version of MariaDB Server. Use this command to build and install a "development" version of MariaDB Server:

Other resources

This page is licensed: CC BY-SA / Gnu FDL

Last updated

Was this helpful?