Installation with Homebrew
brew install mariadb installs the server (mariadbd) and client (mariadb). Start it as a background service with brew services start mariadb. The configuration is /opt/homebrew/etc/my.cnf and the data lives under /opt/homebrew/var/mysql (Apple Silicon; /usr/local on Intel).
Securing the installation
Homebrew's MariaDB starts without a root password. Run mariadb-secure-installation right away to set one, remove anonymous accounts, and drop the test database. Then connect with mariadb -u root -p.
MySQL compatibility
The classic mysql command is provided as a symlink to mariadb, so existing scripts and clients keep working. If you already ran MySQL via Homebrew, uninstall it first — both engines listen on port 3306 and cannot run at the same time.