Back in 2016, we blogged about deploying MariaDB 10.1.16 on Mac OS X with Homebrew. Homebrew now includes MariaDB 10.4, 10.3, 10.2, and 10.1 for macOS. We’ve refreshed this blog to reflect the latest technology. If you need the old blog, you can find it here.

1. Install Xcode

Run xcode-select --install.

  1. MariaDB Server is available as a Homebrew 'bottle', a pre-compiled package. This means you can install it without having to build from source yourself.
  2. If you installed MariaDB with homebrew, use brew services to start and stop the database. It takes only a second and doesn't write strange error to stdout.
Homebrew

Homebrew Formulae. Install command. Conflicts with: mariadb, percona-server. We've installed your MySQL database without a root password. To secure it run. Homebrew installed MariaDb too many open files. Submitted by clemens on Fri, 2020/11/13 - 9:08am. It happened again. I did brew update/upgrade a while ago then weeks after that restarted MariaDB then days later tried to access MariaDB. MariaDb too many open files.

2. Install Homebrew

Run /bin/bash -c '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)'.

Password

Homebrew Mariadb Password

3. Check Homebrew

Run brew doctor. Follow on-screen instructions to fix warnings if necessary.

4. Update Homebrew

Homebrew

Run brew update.

5. Verify MariaDB version in Homebrew repo

Homebrew mariadb password

Run brew info mariadb.

6. Install MariaDB

Run brew install mariadb. Follow on-screen instructions to upgrade if necessary to upgrade a previously installed version.

Homebrew Mariadb Socket

7. Run the database installer

Run mysql_install_db. Follow on-screen instructions to upgrade if necessary to upgrade a previously installed version.

8. Start MariaDB

Run mysql.server start.

Homebrew Mariadb

9. Secure the installation

If you are installing MariaDB 10.4.6 or later:
Run mariadb-secure-installation.
If you are installing an earlier version of MariaDB:
Run mysql_secure_installation.

NOTE: If you are unsure about using unix_socket, do not enable it when asked.
NOTE: Set a root password even if the on-screen instructions tell you it is safe not to do so.

10. Connect to MariaDB

Run mariadb -u root -p.

If you’ve installed an older version of mariadb you may need to use “mysql -u root -p” in the above command.

I have been attempting to install MariaDB on a new MacBook with Catalina installed using Homebrew. However, I hit an issue with the post-install step failing which meant the installation didn’t work. I’m sharing how I managed to successfully install MariaDB here for anyone else that hits a similar problem.

Homebrew Mariadb Default Root Password

To start with I have used Homebrew to install MariaDB on my Mac. I ran brew doctor to make sure there were no problems with Homebrew and resolved anything that came up with the suggested fixes.

Next I did the install for MariaDB.

At this point MariaDB should have successfully installed and I should have been able to run mysql. Unfortunately for me post-install failed with the following message:

The important bit to note here was that there were conflicting my.cnf configuration files. To resolve this, I needed to locate where these files were so that they could be removed:

This returned the path to the file causing post-install to fail. I made a backup of this for precaution and removed the original.

With the configuration file removed I was able to retry post-install:

This ran successfully. MariaDB had successfully installed and could be run via mysql. All that was left to do was set up a root password for mysql and do a bit of a clean-up by removing the backed up my.cnf file.