MariaDB Mac Installation: 10 Easy Steps

|

MariaDB Mac FI

MariaDB is an extremely popular open-source database management system. The platform is known to maintain high compatibility with MySQL. If you did not already know this, then you will be glad to know that the MariaDB Server can be easily installed on macOS with the help of the HomeBrew package manager.

From system requirements to a detailed guide on the installation process, you will find all relevant information to effectively install MariaDB on macOS. All you need to do is check your system compatibility and match the system requirements for MariaDB Mac installation and then follow the steps listed in this article. 

Table of Contents

Prerequisites

  • Working knowledge of MariaDB and Mac OS.
  • Working knowledge of Linux command line.

Introduction to MariaDB and Homebrew

Now, Homebrew also allows you to use MariaDB 10.4, 10.3, 10.2, and 10.1 for macOS. You can upgrade to the MariaDB Server and remove all old MySQL server installs on macOS without any conflicts. 

Homebrew Logo
Image Source

It can be complicated to install MariaDB on macOS when you have a variety of old installs of MySQL servers on your system. This is where Homebrew can be very useful for the installation and up-gradation of MariaDB and utilizing it as a replacement for MySQL. The MariaDB Server is now available as a Homebrew “bottled” pre-compiled package.

This means that you can install it without any need for a building from the source. It can save a lot of time and hassles. Along with the Homebrew “bottled” MariaDB server package, you can also install MariaDB on macOS from the source.

This is useful for someone who needs a different version of MariaDB or needs to enable some different functionalities which cannot be found in the bottle package.

Amongst the components that cannot be found in the bottle package are the CONNECT and OQGRAPH engines because they have non-standard dependencies. In this tutorial, you will learn the steps to install MariaDB on macOS in complete and comprehensive detail.

MariaDB architecture
Image Source

To know more about MariaDB, visit this link.

Understanding Requirements of MariaDB Mac Installation

MariaDB on MacOS
Image Source

There are a few things you need to check into before you start installing MariaDB on macOS. There are a few prerequisites that are crucial for this installation process and the checklist below lists everything you need, to effortlessly complete the installation of MariaDB on macOS. You can take a look at the following checklist of requirements to ensure that you don’t face any discrepancies at a later stage. 

  • Make sure you are operating on the macOS platform.
  • You need to log in as an administrator on your system terminal.
  • You need to install Xcode before you start the installation process. Xcode is an integrated development environment from Apple and it is available on the Mac App Store free of cost.
  • After you have installed Xcode, you need to install the Homebrew on your system. 
  • When you have Homebrew on your system, you will also need to check Homebrew and update the local repository index of the Homebrew package installer if needed. 
  • You can also choose to backup all your current databases with the help of mysqldump
  • It allows you to backup all your MySQL user permissions. Make sure you know and understand your permissions when you remove an existing database. 
  • You will also need to remove MySQL from everywhere it has been inserted into your OS X system. You can either move the folders to a backup folder instead of removing them, or you can remove MySQL completely to avoid any conflicts later on.

If you have all the above points checked on your system, then you can easily install the MariaDB Server on macOS following the tutorial below.  

Simplify your Data Analysis with Hevo’s No-code Data Pipeline

A fully managed No-code Data Pipeline platform like Hevo helps you integrate data from MariaDB and 100+ other data sources (including 40+ Free Sources) to MariaDB in real-time in an effortless manner. Hevo with its minimal learning curve can be set up in just a few minutes allowing the users to load data without having to compromise performance. Its strong integration with umpteenth sources provides users with the flexibility to bring in data of different kinds, in a smooth fashion without having to code a single line. 

Hevo takes care of all your data preprocessing needs required to set up the Integration and lets you focus on key business activities and draw a much powerful insight on how to generate more leads, retain customers, and take your business to new heights of profitability. It provides a consistent & reliable solution to manage data in real-time and always have analysis-ready data in your desired destination.

Get Started with Hevo for Free

Check out some of the cool features of Hevo:

  • Completely Automated: The Hevo platform can be set up in just a few minutes and requires minimal maintenance.
  • Real-Time Data Transfer: Hevo provides real-time data migration, so you can have analysis-ready data always.
  • 100% Complete & Accurate Data Transfer: Hevo’s robust infrastructure ensures reliable data transfer with zero data loss.
  • Scalable Infrastructure: Hevo has in-built integrations for 100+ sources that can help you scale your data infrastructure as required.
  • 24/7 Live Support: The Hevo team is available round the clock to extend exceptional support to you through chat, email, and support calls.
  • Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
  • Live Monitoring: Hevo allows you to monitor the data flow so you can check where your data is at a particular point in time.
Sign up here for a 14-Day Free Trial!

Understanding the MariaDB Mac Installation Steps

Once again, before you learn how to install the MariaDB server on macOS this article will talk about the steps to fulfill some of the prerequisites on your system. After that, you will look into the process of installation of MariaDB on macOS. Here is the list of steps that you’ll be exploring in the following sections:

1) MariaDB Mac Installation: Xcode Installation

Run:

xcode-select --install.
$ xcode-select --install
xcode-select: note: install requested

2) MariaDB Mac Installation: Homebrew Installation

To install Homebrew, the basic procedure to follow is to simply open a terminal and run the following command:

Run:

ruby -e "$(curl-fsSL <a href="https://raw.githubusercontent.com/Homebrew/install/master/install)"" class="rank-math-link">https://raw.githubusercontent.com/Homebrew/install/master/install)"</a>

Or,

Run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)".
$  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/sbin
/usr/local/Caskroom
You can press RETURN to continue or any other key to abort
Password:
==> /usr/bin/sudo /bin/mkdir -p /usr/local/sbin /usr/local/Caskroom
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/sbin /usr/local/Caskroom
==> /usr/bin/sudo /usr/sbin/chown rob /usr/local/sbin /usr/local/Caskroom
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/sbin /usr/local/Caskroom
==> Downloading and installing Homebrew...
remote: Enumerating objects: 5822, done.
remote: Counting objects: 100% (5822/5822), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 24553 (delta 5779), reused 5821 (delta 5779), pack-reused 18731
Receiving objects: 100% (24553/24553), 7.33 MiB | 1.09 MiB/s, done.
Resolving deltas: 100% (18413/18413), completed with 1257 local objects.
...
HEAD is now at 67d1bc6fb Merge pull request #7615 from Bo98/test-dep-satisfied
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.6.3.mavericks.bottle.tar.gz
Updated 1 tap (homebrew/core).
==> New Formulae
...
==> Renamed Formulae
...
==> Deleted Formulae
...
==> Installation successful!
Analytics data hasn’t been sent yet (or will be during this `install` run).
==> Next steps:
- Run `brew help` to get started. 

For further guidance visit the Homebrew Project Website or read the further documentation

3) MariaDB Mac Installation: Homebrew Verification

You will need to follow the instructions displayed on the screen to fix any warnings shown. 

$ brew doctor
Leaving kegs unlinked can cause build trouble and cause the failure of brews that depend on those kegs to run properly once built. Run `brew link` on these:
  gettext
  git 
Warning: Some installed formulae are missing dependencies.
You should `brew install` the missing dependencies:
  brew install openssl@1.1 
Run `brew missing` for more details.
$ brew link gettext git
Linking /usr/local/Cellar/gettext/0.19.8.1... 187 symlinks created
Linking /usr/local/Cellar/git/2.19.1... 
Error: Could not symlink bin/git
Target /usr/local/bin/git
already exists. You may want to remove it:
  rm '/usr/local/bin/git' 
To overwrite all conflicting files and force the link:
  brew link --overwrite git
To list all files that would be deleted:
  brew link --overwrite --dry-run git 

4) MariaDB Mac Installation: Updating Homebrew

Run:

brew update.
$ brew update
Already up-to-date.

5) MariaDB Mac Installation: MariaDB Verification on Homebrew Repo

Before you install MariaDB, you will have to verify the MariaDB version. 

Run:

brew info MariaDB.
$ brew info mariadb
mariadb: stable 10.4.13 (bottled)
Drop-in replacement for MySQL
https://mariadb.org/
Conflicts with:
mariadb-connector-c (because both install plugins)
MySQL (because mariadb, MySQL, and percona install the same binaries)
mytop (because both install `mytop` binaries)
percona-server (because mariadb, MySQL, and percona install the same binaries)
/usr/local/Cellar/mariadb/10.2.14 (641 files, 168.6MB)
Poured from the bottle on 2018-04-30 at 11:34:15
/usr/local/Cellar/mariadb/10.3.10 (652 files, 173.3MB) *
Built from source on 2018-10-12 at 07:16:37
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mariadb.rb
==> Dependencies
Build: cmake ✘, pkg-config ✘
Required: groonga ✘, openssl@1.1 ✔
==> Caveats
A Homebrew-built server might face troubles while starting up due to a "/etc/my.cnf" from another install that may interfere with it.
MySQL only allows connections from localhost by default
To have launched start MariaDB now and restart at login:
brew services start MariaDB
Or, you can just run the following command if you don’t need/want a background service:
MySQL.server start
==> Analytics
install: 15,161 (30 days), 36,985 (90 days), 172,584 (365 days)
install-on-request: 14,780 (30 days), 36,286 (90 days), 168,365 (365 days)
build-error: 0 (30 days)

Before you install MariaDB you need to carry out a few additional instructions:

$ MySQLdump -uroot -p --all-databases --flush-logs --master-data=2 > all_databases.sql
  • Backing up Your MySQL User Permissions
$ MySQLdump -uroot -p MySQL > MySQL.sql
  • Checking Where is MySQL running on Your System 
$ which MySQL

You will see something like: /usr/local/MySQL

Now, you will have to stop the database server:

$ sudo /usr/local/MySQL/support-files/MySQL.server stop

Next, you will have to move, backup or remove the following folders/files:

sudo rm /usr/local/MySQL
sudo rm -rf /usr/local/MySQL*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MySQLCOM=-YES-

Although these files may not exist, if you find them after checking, you have to remove them. It will prevent any conflicts with other versions of MySQL:

sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*MySQL*

6) MariaDB Mac Installation: MariaDB Installation

Here is an instance of the code snippet you would be running:

MariaDB Mac Installation
Image Source

Run

brew install MariaDB. 

Now you will have to follow the on-screen instructions and upgrade if it is necessary to upgrade a previously installed version.

 $ brew install mariadb
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
fonttools 
==> Downloading https://homebrew.bintray.com/bottles/mecab-0.996.mojave.bottle.3.tar.gz
==> Downloading from https://akamai.bintray.com/ef/[...]?__gda__=exp=1590016
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/mecab-ipadic-2.7.0-20070801.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/30/[...]?__gda__=exp=1590016
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/msgpack-3.2.1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3b/[...]?__gda__=exp=1590016
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.44.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ed/[...]?__gda__=exp=1590016
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/groonga-10.0.2.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/df/[...]?__gda__=exp=1590016
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/mariadb-10.4.13.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e4/[...]?__gda__=exp=1590016
######################################################################## 100.0%
Error: mariadb 10.3.10 is already installed
To upgrade to 10.4.13, run `brew upgrade MariaDB.
$ brew upgrade mariadb
==> Upgrading 1 outdated package:
mariadb 10.3.10 -> 10.4.13
==> Upgrading mariadb 10.3.10 -> 10.4.13 
==> Downloading https://homebrew.bintray.com/bottles/cmake-3.17.2.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ed/[...]?__gda__=exp=1590016
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2_3.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/0d/[...]?__gda__=exp=1590016
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/mecab-0.996.mojave.bottle.3.tar.gz
Already downloaded: /Users/rob/Library/Caches/Homebrew/downloads/[...]--mecab-0.996.mojave.bottle.3.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/mecab-ipadic-2.7.0-20070801.mojave.bottle.tar.gz
Already downloaded: /Users/rob/Library/Caches/Homebrew/downloads/[...]--mecab-ipadic-2.7.0-20070801.mojave.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/msgpack-3.2.1.mojave.bottle.tar.gz
Already downloaded: /Users/rob/Library/Caches/Homebrew/downloads/[...]--msgpack-3.2.1.mojave.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.44.mojave.bottle.tar.gz
Already downloaded: /Users/rob/Library/Caches/Homebrew/downloads/[...]--pcre-8.44.mojave.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/groonga-10.0.2.mojave.bottle.tar.gz
Already downloaded: /Users/rob/Library/Caches/Homebrew/downloads/[...]--groonga-10.0.2.mojave.bottle.tar.gz
==> Downloading https://downloads.mariadb.com/MariaDB/mariadb-10.4.13/source/mariadb-10.4.13.tar.gz
######################################################################## 100.0%
==> Installing dependencies for mariadb: cmake, pkg-config, mecab, mecab-ipadic, msgpack, pcre and groonga
==> Installing mariadb dependency: cmake
==> Pouring cmake-3.17.2.mojave.bottle.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cmake
==> Summary
🍺  /usr/local/Cellar/cmake/3.17.2: 6,156 files, 58.1MB
==> Installing mariadb dependency: pkg-config
==> Pouring pkg-config-0.29.2_3.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.2_3: 11 files, 623.6KB
==> Installing mariadb dependency: mecab
==> Pouring mecab-0.996.mojave.bottle.3.tar.gz
🍺  /usr/local/Cellar/mecab/0.996: 20 files, 4.2MB
==> Installing mariadb dependency: mecab-ipadic
==> Pouring mecab-ipadic-2.7.0-20070801.mojave.bottle.tar.gz
==> Caveats
To enable mecab-ipadic dictionary, add to /usr/local/etc/mecabrc:
  dicdir = /usr/local/lib/mecab/dic/ipadic
==> Summary
🍺  /usr/local/Cellar/mecab-ipadic/2.7.0-20070801: 16 files, 50.6MB
==> Installing mariadb dependency: msgpack
==> Pouring msgpack-3.2.1.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/msgpack/3.2.1: 757 files, 5.2MB
==> Installing mariadb dependency: pcre
==> Pouring pcre-8.44.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/pcre/8.44: 204 files, 5.5MB
==> Installing mariadb dependency: groonga
==> Pouring groonga-10.0.2.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/groonga/10.0.2: 886 files, 39.5MB
==> Installing mariadb
==> cmake . -DMySQL_DATADIR=/usr/local/var/MySQL -DINSTALL_INCLUDEDIR=include/MySQL -DINSTALL_MANDIR=share/man -DINSTALL_DOCDIR=share/d
==> make
==> make install
==> Not running post_install as the user is building a bottle
You can run it manually using `brew postinstall mariadb`
==> Caveats
A Homebrew-built server might face troubles while starting up due to a "/etc/my.cnf" from another install that may interfere with it.
MySQL only allows connections from localhost by default
To have launched start MariaDB now and restart at login:
  brew services start MariaDB
Or, you can just run the following command if you don’t need/want a background service:
  MySQL.server start
==> Summary
🍺  /usr/local/Cellar/mariadb/10.4.13: 737 files, 170.0MB, built in 8 minutes 53 seconds
Removing: /usr/local/Cellar/mariadb/10.2.14... (641 files, 168.6MB)
Removing: /usr/local/Cellar/mariadb/10.3.10... (652 files, 173.3MB)
Removing: /Users/rob/Library/Caches/Homebrew/mariadb--10.3.10.tar.gz... (67.2MB)
==> Checking for dependents of upgraded formulae...
==> No dependents found!
==> Caveats
==> cmake
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cmake
==> mecab-ipadic
To enable mecab-ipadic dictionary, add to /usr/local/etc/mecabrc:
  dicdir = /usr/local/lib/mecab/dic/ipadic
==> mariadb
A Homebrew-built server might face troubles while starting up due to a "/etc/my.cnf" from another install that may interfere with it.
MySQL only allows connections from localhost by default
To have launched start MariaDB now and restart at login:
  brew services start MariaDB
Or, you can just run the following command if you don’t need/want a background service:
  MySQL.server start

7) MariaDB Mac Installation: Running the Database Installer

After the installation process is completed, you will have to install the database. 

Run:

MySQL_install_db. 

Now you will have to follow the on-screen instructions and upgrade if it is necessary to upgrade a previously installed version. 

$ MySQL_install_db
WARNING: The host 'robs-MacBook-Pro-2.local' could not be looked up with /usr/local/Cellar/mariadb/10.4.13/bin/resolveip.
This could mean that your libc libraries may not be 100% compatible
with this binary MariaDB version. The MariaDB daemon, MySQL, should work normally with the exception that hostname resolving will not work.
Therefore you should use IP addresses to replace hostnames
when specifying MariaDB privileges!
MySQL.user table already exists!
Run MySQL_upgrade, not MySQL_install_db
$ MySQL_upgrade
Phase 1/7: Checking and upgrading MySQL database
Processing databases
...
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK

8) MariaDB Mac Installation: Starting MariaDB

Here is an example of the code snippet that will be used to start MariaDB:

Starting MariaDB on macOS
Image Source

MariaDB will not start automatically after installation. To do so, you will first have to start the MySQL server. 

Run

MySQL.server start.
$ MySQL.server start
Starting MySQL
. SUCCESS!

Then, follow the following commands:

Run

ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist

To stop MariaDB, use the unload command.

Run

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist

9) MariaDB Mac Installation: Securing Installation

The installer will not set a password for the root user by default. Right after getting MariaDB running on Mac OS, run the MySQL_secure_installation script.

To install MariaDB 10.4.6 or later:

Run:

MariaDB-secure-installation.

For installing an earlier version of MariaDB:

Run:

MySQL_secure_installation.

If you are not sure about using unix_socket, do not enable it when asked.

You can set a root password even if the on-screen instructions tell you it is safe without it.

$ MySQL_secure_installation
To log into MariaDB to secure it, you'll need the current
password for the root user. If you've just installed MariaDB, 
you should just press enter here if you haven't set the root password yet.
Enter current password for root (enter for none):  
Using the unix_socket or setting the root password ensures that nobody can log into the MariaDB root user without the proper authentication and authorization.
Enable unix_socket authentication? [Y/n] n
 ... skipping. 
Since you already have your root account protected you can safely go ahead and answer 'n'. 
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!  
MariaDB installation has an anonymous user that allows anyone to log into MariaDB without having to have a user account created for them by default.  This is meant to make the installation go a bit smoother and for testing purposes. Before shifting to a production environment you should remove them. 
Remove anonymous users? [Y/n] y
 ... Success! 
Normally, the root should only be allowed to connect from 'localhost.’  This ensures that someone cannot guess the root password from the network. 
Disallow root login remotely? [Y/n] y
 ... Success! 
MariaDB comes with a database named 'test' that can be accessed by anybody by default. This is meant for testing purposes and before shifting to a production environment you should remove them. 
Remove the test database and access it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
You can ensure that all changes made so far will take effect immediately by reloading the privilege tables.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...
All done!  If you're done with all the steps mentioned so far, your MariaDB installation should now be secure.
Thanks for using MariaDB!

10) MariaDB Mac Installation: Connecting 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.

$ MariaDB -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with; or g.
Your MariaDB connection id is 52
Server version: 10.4.13-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)]>

After the installation of the new MariaDB server, you can restore the MySQL database. 

Run

$ MySQL -uroot -p MySQL < MySQL.sql

You also have to ensure that you flush privileges for the new user permissions to take effect. 

Run

FLUSH PRIVILEGES

Conclusion

This article highlighted the key steps that can help you seamlessly install MariaDB on macOS. Not only can you avoid any conflicts with the existing MySQL components, but you can also easily restore the databases if you have backed up all the databases as instructed in the tutorial above.

By following these steps, you can bypass any database problems or version mismatches and install MariaDB on macOS without any hassles. Along with that, the brew installer can be used to install more open-source software packages as it works as a Linux package manager.

Visit our Website to Explore Hevo

Businesses can use automated platforms like Hevo Data to set the integration and handle the ETL process. It helps you directly transfer data from MariaDB to a Data Warehouse, Business Intelligence tools, or any other desired destination in a fully automated and secure manner without having to write any code and will provide you a hassle-free experience.

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.

Share your experience of learning about MariaDB Mac Installation in the comments section below!

Bhavik Soni
Freelance Technical Content Writer, Hevo Data

Bhavik is an expert in freelance writing within the data industry, seamlessly producing informative and engaging content focused on data science by leveraging his problem-solving skills.

No-code Data Pipeline for your Data Warehouse