Installing homebrew
brew -v
#See if homebrew is available
brew doctor
Install MySQL 5.7
#Search MySQL version
brew search mysql
#Installation 5.7
brew install [email protected]
#Configure environment variables, as shown in red box 1 below
echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
#Make configuration effective
source ~/.zshrc
#Start MySQL service
mysql.server start
MySQL set password
After MySQL is installed, there is no password configured. MySQL is configured to allow only connections from localhost by default
#Enter the password modification command prompted after installation
mysql_secure_installation
#The simple password cannot be set. The password strength verification plug-in validate is added_ password
... Failed! Error: Your password does not satisfy the current policy requirements
#View authentication password policy
mysql> select @@validate_password_policy;
+----------------------------+
| @@validate_password_policy |
+----------------------------+
| LOW |
+----------------------------+
#View several global parameters related to MSYQL password
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
#Modify MySQL parameter configuration
mysql> set global validate_password_mixed_case_count=0;
mysql> set global validate_password_number_count=0;
mysql> set global validate_password_special_char_count=0;
mysql> set global validate_password_length=3;
#Check whether the modification is successful
mysql> SHOW VARIABLES LIKE 'validate_password%';
#Change password
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');