Skip to content

Installing MariaDB on Mac

First, you need to install Homebrew package manager for Mac. To do so, just run this on your terminal and follow the installation instructions:

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

Now, after installing Homebrew or Brew, you'll have the ability to install packages from Homebrew package repository, like you can with Ubuntu Linux.

First, before you can install software, you'll need to obtain the latest versions of software. To do so, run this first:

Text Only
brew update

Then, to install MariaDB, just run:

Text Only
brew install mariadb

And then start the server with:

Text Only
mysql.server start

Now we only need to do one more thing. Now when you restart your computer, you need to start the server again. We can use this command to start the MySQL server automatically each time your computer restarts:

Text Only
brew services start mariadb

Problems Installing?

If you are having problems installing mariadb using the commands above, try to run this command:

Text Only
brew doctor

Setting root password

By default the Homebrew installation of MariaDB might not include the root password set for root user that we will require to connect from external tools. We can set this by executing this command:

Text Only
sudo $(brew --prefix mariadb)/bin/mysqladmin -u root password root

This sets the password root for the user root.

Testing the Installation

To test the installation, just run:

Text Only
mysql

Which should start the MySQL CLI (Command-Line Interface).

Exiting from the MySQL Command Line Interface

To exit from the MySQL Command Line Interface (CLI), just write:

MySQL
exit

Or press:

Text Only
ctrl + c

Installing mycli

There is also a great command line interface available for MariaDB called mycli that I recommend using during this course. This command line interface includes auto-completion and syntax highlighting.

To install mycli, just run:

Text Only
brew update && brew install mycli

OR if that does not work, try:

Text Only
pip3 install mycli

And after the installation, just run this to launch into mycli:

Text Only
mycli

And to exit from mycli run this:

MySQL
exit