1, install MySQL, install through homebrew
Brew Install MySQL
2. Set the password
Through the brew installed MySQL default is not set the password link, looked at the evening information, someone is set by/usr/local/etc/my.cnf not enter the password login,
I used a different method to initialize the password.
unset TEMDIRmysqld -initialize --verbose --user=root --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmpmysql.server startmysql_secure_installation (abc123456.)
The password is in parentheses.
3. Reset Password
SHOW VARIABLES LIKE ‘validate_password%‘;SET GLOBAL validate_password_policy = ‘LOW‘;SET GLOBAL validate_password_length = 4;set password for ‘root‘@‘localhost‘=password(‘root’);
In order to set a simple password, you need to reduce the default password security level.
4. Start and close MySQL
Start MySQL
mysql.server start
Turn off MySQL
mysql.server stop
Mac install MySQL