We are pretty adamant about using n0c0de for our services. However, we are more about making awesome things, getting this done and making customer happy!

Sometimes, we come across a tool that requires little code but the leverage we are able to derive blows our mind! A recent such tool that we came across that led us to break our own rules is ERPNext. For the record, the previous one was n8n.io

More on ERPNext later! We will most like end-up writing an entire series around it. We just can’t get enough of the power and agility ERPNext provides us. Stay tuned!

A basic pre-requisite of ERPNext is Mariadb. We use MacOS Catalina for development.

This post is about installing and securing Mariadb on Macos Catalina.

As background, doing this on our system turned to be more painful than a typical Mac experience :-(

This post will hopefully save others a ton of time!

So, lets dive in!

Install mariadb

Installing mariadb with homebrew is pretty simple. Just follow the below commands in your terminal and you should do fine!

# install mariadb
brew install mariadb

# optional. check for installation info.
brew info mariadb

Mariadb should be installed. Easy peasy!

Verify the installation using:

# check services list
brew services list

You should see mariadb running!

check for mariadb service
check for mariadb service!

To visually inspect, check it out in the MacOS Activity Monitor too!


Secure mariadb root password

This is where things got (very) painful! Securing mariadb threw up a lot of results in Stack Overflow and after many hours of trials. The following worked for us!

# stop mariadb
brew services stop mariadb

# check again if maridb is running
brew services list

# if it still doesn't work .. try
# kill the process
pkill mariadbd

# check in activity monitor to be 100% sure

To be absolutely sure, terminal and activity monitor should show that mariadb has stopped!


Now, to securing mariadb by setting the root password, this turned out to be more complicated than expect. The following worked for us!

Note! We will delete the existing database. Which was OK for us!

# NOTE: this will delete your existing database!!! CAREFUL
rm -rf /usr/local/var/mysql/

# recreate the initial files for mariadb
brew postinstall mariadb

# check for mariadb. also use Activity Monitor to be sure!
brew services list

brew services start mariadb
brew services list

brew services stop mariadb

sudo mysql_secure_installation
# the default password is blank

# login using the new password
mysql -uroot -p
Run mysql_secure_installation to secure mariadb by setting a root password and limit to localhost

Note: we didn’t use unix_socket_authentication

Verify Mariadb Login By Using A Root Password
Verify Mariadb Login By Using A Root Password

That’s it! Hope it was useful!

Drop us a note if it did! ;-)

Like to discuss a project? Email us using the contact form