brew install mysql
brew tap homebrew/services
brew services start mysql
If you run into this error using GUI tools, e.g. Sequel Pro:
Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found
Then do the following steps:
vi /usr/local/etc/my.cnf
in section [mysqld]
add line:
default-authentication-plugin=mysql_native_password
Login to mysql with mysql -u root -p
:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
And then restart:
brew services restart mysql
brew services stop mysql