Installing MariaDB on MacOS with Homebrew
MariaDB is a community-driven fork of the then open sourced MySql which was acquired by Oracle, and it is created by the original developers of MySql, and is still highly compatible with MySql.
Usually installing and running such databases is pretty straightforward, there is usually a default root
user with no password. However, if you install it with Homebrew using brew install mariadb
, it didn’t quite happen as expected. So after installation, if you try to login with mariadb -u root -p
, you’ll get an error message like this:
Access denied for user 'root'@'localhost' (using password: NO)
So actually the root was created with another password. But there is also another user created with the current MacOS username. For example, my username is dennis, so I can still login with mysql -u dennis -p
. Then we can alter the root password with
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
We need to do the flush privileges to get the server to re-read the user accounts and privileges from the underlying grant tables without requiring a server restart, because when we make changes to the user accounts, privileges, or roles, these changes are stored in memory, and not immediately applied until the flush privileges statement. Then now we can log in with the root user.
It’s not ideal to access the database from the terminal, so in MacOS, I’ll use Sequel Pro, a free and clean looking MySQL client to access the MariaDB.