乐趣区

关于mysql:Homebrew安装mysql-57

装置 Homebrew

https://brew.sh/

brew -v

# 查看 homebrew 是否可用
brew doctor

装置 mysql 5.7

# 搜寻 mysql 版本
brew search mysql

# 装置 5.7
brew install mysql@5.7

# 配置环境变量,如下图红框 1
echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

# 使配置失效
source ~/.zshrc

# 启动 mysql 服务
mysql.server start

mysql 设置明码

mysql 装置完是没有配置明码的,MySQL 被配置为默认只容许来自 localhost 的连贯

# 输出装置后,提醒的批改明码的命令
mysql_secure_installation


# 无奈设置简略明码,减少了明码强度验证插件 validate_password
 ... Failed! Error: Your password does not satisfy the current policy requirements


# 查看 验证明码策略
mysql> select @@validate_password_policy;
+----------------------------+
| @@validate_password_policy |
+----------------------------+
| LOW                        |
+----------------------------+


# 查看 msyql 明码相干的几个全局参数
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     |
+--------------------------------------+-------+


# 批改 mysql 参数配置

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;


# 查看 是否批改胜利
mysql> SHOW VARIABLES LIKE 'validate_password%';


# 批改明码
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
退出移动版