Homebrew安装mysql 5.7

安装Homebrew
https://brew.sh/
Homebrew安装mysql 5.7
文章图片

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

Homebrew安装mysql 5.7
文章图片

mysql 设置密码
【Homebrew安装mysql 5.7】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');

    推荐阅读