Install MariaDB (10.5.8.-GA) via Homebrew on macOS
201117
In case you don’t have yet installed Homebrew on your macOS, you can proceed and install it following the instructions here. If you have already done it, you can update it:
$ brew update
You can find and download the latest version of MariaDB at :
https://mariadb.com/downloads/. In our case this was the 10.5.8-GA version.
However, here were the specific instructions to install it via Homebrew:
https://mariadb.com/resources/blog/installing-mariadb-10-1-16-on-mac-os-x-with-homebrew/
Moreover, MariaDB Knowledge Base is also a worth to visit place to obtain vital information for installing MariaDB via Homebrew:
https://mariadb.com/kb/en/installing-mariadb-on-macos-using-homebrew/
Installing MariaDB
To install MariDB just paste the command below, at a Terminal prompt:
$ brew install mariadb
➜ ~ brew update Already up-to-date. ➜ ~ brew install mariadb ==> Downloading https://homebrew.bintray.com/bottles/mecab-0.996.mojave.bottle.3.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/ef261d203140305ca8c9e4b7311c61176a17325df9454610d3eb33a312c4d3c5?response-content- ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/mecab-ipadic-2.7.0-20070801.mojave.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/30967b4167d34f05c79f185d71a40198fff4067d0cce82aed59383548c898681?response-content- ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/msgpack-3.3.0.mojave.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/f418d11d056dd08160b27088d19ee12d4a9e36dbd913ffae8d2c9838a1449475?response-content- ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/groonga-10.0.8.mojave.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/83652aa36bcc991d767a4eca69a7798515b9fa0aaecb58605f78f3cb763643f6?response-content- ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/mariadb-10.5.8.mojave.bottle.1.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/b22a037c88a4327dea62f83cc60c0ad70855c1e078625d7eb7c483bf3f7d3e30?response-content- ######################################################################## 100.0% ==> Installing dependencies for mariadb: mecab, mecab-ipadic, msgpack and groonga ==> 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.3.0.mojave.bottle.tar.gz ? /usr/local/Cellar/msgpack/3.3.0: 757 files, 5.2MB ==> Installing mariadb dependency: groonga ==> Pouring groonga-10.0.8.mojave.bottle.tar.gz ? /usr/local/Cellar/groonga/10.0.8: 921 files, 40.0MB ==> Installing mariadb ==> Pouring mariadb-10.5.8.mojave.bottle.1.tar.gz ==> /usr/local/Cellar/mariadb/10.5.8/bin/mysql_install_db --verbose --user=zafeiropoulospanos --basedir=/usr/local/Cellar/mariadb/10.5.8 --da ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. MySQL is configured to only allow connections from localhost by default To have launchd start mariadb now and restart at login: brew services start mariadb Or, if you don't want/need a background service you can just run: mysql.server start ==> Summary ? /usr/local/Cellar/mariadb/10.5.8: 784 files, 179.9MB ==> Caveats ==> mecab-ipadic To enable mecab-ipadic dictionary, add to /usr/local/etc/mecabrc: dicdir = /usr/local/lib/mecab/dic/ipadic ==> mariadb A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. MySQL is configured to only allow connections from localhost by default To have launched start mariadb now and restart at login: brew services start mariadb Or, if you don't want/need a background service you can just run: mysql.server start ➜ ~
NB: We can also make a secure installation of MariaDB (10.4.6 or later):
$ mariadb-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.
Starting the MariaDB
Using brew services command you can start MariaDB, as well as to automatically start it every time your macOS boots or restarts.
$ brew services start mariadb
➜ ~ ➜ ~ ➜ ~ brew services start mariadb ==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb) ➜ ~ ➜ ~
NB: You can also use the ‘classic’ command below to start it ad-hoc (not via brew):
$ $ mysql.server start
NOTE: For starting a brew service just once: Avoid using mysql.server start, since MariaDB has been installed via Brew/HomeBrew in macOS. Using it might be tricky since you might encounter problems when you use for instance:
mysql.server status, mysql.server stop, etc.
e.g.:
➜ ~ ➜ ~ mysql.server stop ERROR! MariaDB server PID file could not be found! ➜ ~ ➜ ~
However, MariaDB might be is up and running:
➜ ~ ps aux | grep mysq zp 34065 0.0 0.1 4773460 9148 ?? S Sat12PM 0:43.76 /usr/local/Cellar/mariadb/10.5.8/bin/mariadbd --basedir=/usr/local/Cellar/mariadb/10.5.8 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mariadb/10.5.8/lib/plugin --log-error=/usr/local/var/mysql/pzMacBookPro.local.err --pid-file=/usr/local/var/mysql/pzMacBookPro.local.pid zp 33998 0.0 0.0 4279776 416 ?? S Sat12PM 0:00.03 /bin/sh /usr/local/Cellar/mariadb/10.5.8/bin/mysqld_safe --datadir=/usr/local/var/mysql --pid-file=/usr/local/var/mysql/pzMacBookPro.local.pid zp 52769 0.0 0.0 4277148 684 s000 S+ 3:16PM 0:00.01 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysq ➜
This mainly happens sometimes, due to arbitrary miss stopped or accidentally killed process. Instead use the brew services commands:
$ brew services run mariadb $ brew services stop mariadb
Using MariaDB command line
The very first time (after you have started it via brew) you can use just ‘mariadb’ to connect:
$ mariadb
➜ ~ mariadb Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 6 Server version: 10.5.8-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)]> MariaDB [(none)]> MariaDB [(none)]>
Then you can check the status:
MariaDB [(none)]> MariaDB [(none)]> status -------------- mariadb Ver 15.1 Distrib 10.5.8-MariaDB, for osx10.14 (x86_64) using readline 5.1 Connection id: 6 Current database: Current user: zp@localhost SSL: Not in use Current pager: less Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.5.8-MariaDB Homebrew Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: latin1 Conn. characterset: latin1 UNIX socket: /tmp/mysql.sock Uptime: 6 min 21 sec Threads: 2 Questions: 4 Slow queries: 0 Opens: 16 Open tables: 10 Queries per second avg: 0.010 -------------- MariaDB [(none)]>
Additionally, you can check the help (\h) and quit (\q):
MariaDB [(none)]> \h General information about MariaDB can be found at http://mariadb.org List of all client commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to MariaDB server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to MariaDB server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server-side help, type 'help contents' MariaDB [(none)]> \q Bye ➜ ~
That’s it!
Thank you for reading!