Just in case `mysql_secure_installation` doesn’t work after a new mysql 8 installation.
Install MySQL
brew install mysql
Stop it
brew services stop mysql
Start the safe mode
/usr/local/Cellar/mysql/8.0.11/bin/mysqld_safe
Login and skip password
mysql -u root --skip-password
Change password and exit
ALTER USER 'root'@'localhost' IDENTIFIED BY 'a-new-password'; exit;
Stop safe mode mysql
mysql.server stop
Start mysql
Create `~/.my.cnf` with following content
[client] host = localhost user = root password = a-new-password