Menu

How to Install MariaDB on macOS with Homebrew

Install MariaDB Server on macOS with Homebrew, start it as a login service, connect through the local account, and create a restricted application user.

Posted on By Updated on
On this page

Homebrew provides MariaDB Server as a precompiled macOS package. This guide installs the current MariaDB formula and starts it as a background service. Check the Homebrew formula page for supported macOS versions and the current release.

Prerequisites

  • A macOS version supported by Homebrew.
  • Terminal access and an internet connection.
  • Homebrew. If it is not installed, use the current instructions on the Homebrew website.

1. Install MariaDB

Refresh Homebrew’s formula metadata and install MariaDB:

brew update
brew install mariadb

The mariadb formula can conflict with other MySQL-compatible formulas that install the same command-line tools. If you already have MySQL or Percona Server installed with Homebrew, review the formula’s conflict notes before proceeding.

2. Start MariaDB

Start MariaDB as a background service that launches when you log in:

brew services start mariadb

Check the service if it does not start:

brew services list

To stop it later, run brew services stop mariadb.

3. Run the security setup

Run MariaDB’s setup utility and review each prompt:

sudo mariadb-secure-installation

The utility can remove anonymous accounts, disallow remote root access, and remove the test database. MariaDB 10.4 and later commonly use Unix socket authentication for the local root account, so setting a root password may not be necessary. Choose the options that match your local setup; do not enable remote root access for a development server.

4. Connect locally

With a standard Homebrew installation, connect as your macOS account:

mariadb

Confirm that the server responds:

SELECT VERSION(), CURRENT_USER();

If you configured password authentication for a database account, connect with mariadb -u account_name -p and enter its password when prompted.

5. Create a database and application account

In the MariaDB prompt, create a database and a runtime account. Use a unique secret from a password manager. This account can read and modify rows; create a separate migration account if the application needs to change the schema.

CREATE DATABASE mydatabase;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'replace-with-a-unique-secret';
GRANT SELECT, INSERT, UPDATE, DELETE ON mydatabase.* TO 'myuser'@'localhost';

Exit the client and test the new account:

exit;
mariadb -u myuser -p mydatabase

Enter the account password when prompted. From the MariaDB prompt, verify the account and selected database:

SELECT CURRENT_USER(), DATABASE();

Upgrade MariaDB

To update Homebrew’s package metadata and upgrade MariaDB when a newer formula is available, run:

brew update
brew upgrade mariadb

If MariaDB is running as a background service, restart it after an upgrade:

brew services restart mariadb

See MariaDB’s official macOS Homebrew installation guide for configuration paths and more service details.