Errors and Attempts During MariaDB (or MySQL) Installation Using HomeBrew on macOS.
There are a bunch of errors related to MariaDB, which was installed after MySQL with homebrew on MacOS. I face a lot of issues and restarted/reinstalled it thousand times as I was willing to connect to db shell with "mysql.server start" . I have no idea why the exact reason was, possibly, these issues may have originated from the location of the "my.cnf" file. It left me utterly stuck and hopeless to go further... 😫😫😫😫😫
I eventually gave up trying it and switched to the most-recommended one to start the db, following the guide below.
1) Kill all processes triggered by previous commands.
ps aux | grep mysql
sudo kill [pid] [pid] ...
2) Restart the service.
brew services restart mariadb
3) connect to mysql with "sudo"
sudo mysql -u root -p
use mysql
4) Set your initial password inside "PASSWORD("HERE")".
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("1234");
5) Exit and reconnect
exit
sudo mysql -u root -p
I totally understand that using "brew services" is the correct one, but hope to figure out the underlying reasons in depth.
What I tried was on my MacOS (Ventura 13.4.1, MariaDB 11.0.2_1)
- Remove "mysql" inside "opt/homebrew/var".
- Unlink/remove/uninstall and cleanup brew.
- Grant a permission (with "chown" cmd).
- Install other packages such as "mysql_install_db" and etc.
- Remove or Move "my.cnf" (it located in /opt/homebrew/etc in my case).
- etc.
The most headache issues were the following:
- The server quit without updating PID file.
brew services restart mysql
mysql.server start
- ERROR 2002 (HY000): Can't connect to local server through socket '/tmp/mysql.sock' (2)
mysql -u root -p
- Error: No such keg: /opt/homebrew/Cellar/mariadb
brew unlink mariadb
brew remove mariadb
brew uninstall mariadb
## the error occurs here.
- ERROR! MariaDB is not running, but PID file exists
sudo mysql.server status
- Error: Cannot install mysql because conflicting formulae are installed. mariadb: because mysql, mariadb, and percona install the same binaries
## prerequisite : mariadb was installed => trying to install mysql
brew update mysql