mac nginx 非brew安装_Mac——brew替换源地址&安装配置mysql@5.7版本

╰半夏微凉° 2023-01-03 01:49 290阅读 0赞

问题描述:使用brew方式安装mysql,存在以下问题:1.由于mysql已经升级到8.x版本,会默认安装8.x版本,会对之前部分特性不友好支持;2.brew默认安装源下载响应时间非常慢,下载时间过长容易超时;

问题解决:问题一通过brew search mysql可以查看到是有历史版本可以下载的包括经典的5.7版本;

a26b86afdaa603542f16c884f42bf20b.png

问题二需要更换brew源地址,具体更换源地址如下:

问题延伸:网上搜索大家都说跳转到/usr/local目录下使用git remote操作,结果如下:

  1. $ git remote -v
  2. fatal: Not a git repository (or any of the parent directories): .git

这就很无语了,后来终于找到另一种姿势(使用环境变量去找);

替换以下几个镜像源:

替换为中科大的镜像:

替换brew.git:

  1. cd "$(brew --repo)"
  2. git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

替换homebrew-core.git:

  1. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
  2. git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

替换成功后更新下源:

  1. brew update

对于bash用户:

  1. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
  2. source ~/.bash_profile

对于zsh用户:

  1. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
  2. source ~/.zshrc

也可以选择替换清华大学镜像(和上边部分效果相同):

替换brew.git:

  1. cd "$(brew --repo)"
  2. git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

替换homebrew-core.git:

  1. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
  2. git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
  3. brew update

使用homebrew-science或者homebrew-python还需要替换

  1. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-science"
  2. git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-science.git
  3. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-python"
  4. git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-python.git
  5. brew update

对于bash用户:

  1. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
  2. source ~/.bash_profile

对于zsh用户:

  1. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
  2. source ~/.zshrc

替换好brew源地址安装mysql@5.7就会轻松很多;

brew源配置生效后使用brew install mysql@5.7安装即可;

安装完成后提示如下:

  1. We've installed your MySQL database without a root password. To secure it run:
  2. mysql_secure_installation #初始化配置
  3. MySQL is configured to only allow connections from localhost by default
  4. To connect run:
  5. mysql -uroot #运行连接
  6. mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
  7. because this is an alternate version of another formula.
  8. If you need to have mysql@5.7 first in your PATH run: #配置环境变量
  9. echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
  10. For compilers to find mysql@5.7 you may need to set:
  11. export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib" #想要系统编译运行认识mysql@5.7配置环境变量
  12. export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
  13. To have launchd start mysql@5.7 now and restart at login:
  14. brew services start mysql@5.7 #启动安装后的mysql数据库
  15. Or, if you don't want/need a background service you can just run:
  16. /usr/local/opt/mysql@5.7/bin/mysql.server start #通过配置文件启动mysql数据库

根据安装后提示信息第一步配置环境变量:

家目录下,vi .bashprofile文件,将安装后提示的:

export PATH=”/usr/local/opt/mysql@5.7/bin:$PATH”

export LDFLAGS=”-L/usr/local/opt/mysql@5.7/lib”

export CPPFLAGS=”-I/usr/local/opt/mysql@5.7/include”

加入到.bash_profile文件中,加入保存后使用source .bashprofile使配置到环境变量生效;

完成后使用:brew services start mysql@5.7或者你根据配置文件启动mysql数据库,服务启动后开始初始化配置;

运行:mysql_secure_installation

提示如下:

  1. Securing the MySQL server deployment.
  2. Connecting to MySQL using a blank password.
  3. VALIDATE PASSWORD PLUGIN can be used to test passwords
  4. and improve security. It checks the strength of password
  5. and allows the users to set only those passwords which are
  6. secure enough. Would you like to setup VALIDATE PASSWORD plugin?
  7. Press y|Y for Yes, any other key for No: k //是否采用mysql密码安全检测插件,我本地使用果断拒绝了,因为密码检查插件要求密码复杂程度高,大小写字母+数字+字符等
  8. Please set the password for root here. // 首次使用自带配置脚本,设置root密码
  9. New password:
  10. Re-enter new password:
  11. By default, a MySQL installation has an anonymous user,
  12. allowing anyone to log into MySQL without having to have
  13. a user account created for them. This is intended only for
  14. testing, and to make the installation go a bit smoother.
  15. You should remove them before moving into a production
  16. environment.
  17. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y //是否删除匿名用户
  18. Success.
  19. Normally, root should only be allowed to connect from
  20. 'localhost'. This ensures that someone cannot guess at
  21. the root password from the network.
  22. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y //是否禁止远程登录
  23. Success.
  24. By default, MySQL comes with a database named 'test' that
  25. anyone can access. This is also intended only for testing,
  26. and should be removed before moving into a production
  27. environment.
  28. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y //删除测试数据库,并登录
  29. - Dropping test database...
  30. Success.
  31. - Removing privileges on test database...
  32. Success.
  33. Reloading the privilege tables will ensure that all changes
  34. made so far will take effect immediately.
  35. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y //重新载入权限表
  36. Success.
  37. All done!

配置完成,使用mysql -uroot -p,然后输入配置到root密码登陆到mysql数据库;

发表评论

表情:
评论列表 (有 0 条评论,290人围观)

还没有评论,来说两句吧...

相关阅读