适配 Intel macOS,兼容你本地7890代理、Git GitHub加速,全程终端操作
前置说明
- 系统:Intel Mac(x86_64)
- 本地代理地址:
127.0.0.1:7890 - 包含:Homebrew、MySQL8.0、DBeaver可视化工具、brew/Git代理优化
一、安装 & 配置 Homebrew(Intel专用路径)
1. 检查brew是否存在
bash
brew --version
无版本输出则执行安装脚本:
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. Intel芯片配置环境变量(关键,和M芯片路径不同)
安装结束后终端会输出环境命令,复制执行:
bash
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zshrc
source ~/.zshrc
3. 配置brew代理,解决下载卡顿(永久生效)
bash
nano ~/.zshrc
文件末尾粘贴以下内容:
zsh
# 本地7890代理,brew/git/终端全局生效
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export ALL_PROXY=socks5://127.0.0.1:7890
保存退出:Ctrl+O 回车 → Ctrl+X
刷新配置:
bash
source ~/.zshrc
二、安装 MySQL 8.0(Intel通用稳定版)
1. 安装MySQL
bash
brew install mysql@8.0
2. 后台启动+开机自启
bash
brew services start mysql@8.0
# 查看运行状态
brew services list
看到 mysql@8.0 started 代表服务正常运行。
3. 安全初始化(设置root密码,必操作)
bash
mysql_secure_installation
交互选项一步一步选:
- Validate password component:输入
n(本地开发不用强密码) - Set root password:自定义数据库密码(如
123456) - Remove anonymous users:
y - Disallow root login remotely:
y(禁止外网访问,本地开发安全) - Remove test database:
y - Reload privilege tables:
y
4. 验证登录MySQL
bash
mysql -u root -p
输入刚才设置的密码,出现 mysql> 提示符即成功;输入 exit; 退出数据库终端。
MySQL 启停常用命令
bash
# 启动服务
brew services start mysql@8.0
# 停止服务
brew services stop mysql@8.0
# 重启(修改配置后使用)
brew services restart mysql@8.0
三、安装 DBeaver 社区版(可视化数据库工具)
方式1:Homebrew一键安装(推荐)
bash
brew install --cask dbeaver-community
安装完成打开软件:
bash
open /Applications/DBeaver.app
方式2:官网DMG手动安装(brew下载慢时备选)
- 打开官网下载页:https://dbeaver.io/download/
- macOS分类选择 Intel DMG 安装包下载
- 双击dmg文件,将
DBeaver.app拖拽到「应用程序」文件夹 - 首次打开提示无法验证开发者:系统设置 → 隐私与安全性,下滑点击「仍要打开」
DBeaver连接MySQL配置
- 打开软件,左侧「新建连接」,选择 MySQL
- 连接参数:
- 主机:
127.0.0.1 - 端口:
3306 - 用户:
root - 密码:你初始化设置的MySQL密码
- 主机:
- 首次连接会自动下载MySQL驱动,等待完成后即可正常操作数据库
四、配套:GitHub SSH/HTTPS 专属代理(你之前的Git加速配置)
1. SSH克隆专用代理(解决clone断线、慢)
bash
nano ~/.ssh/config
写入配置:
ssh
Host github.com
HostName github.com
User git
ProxyCommand nc -x 127.0.0.1:7890 %h %p
IdentityFile ~/.ssh/id_ed25519
权限修复(Intel/M芯片通用)
bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/config
2. HTTPS克隆仅GitHub走代理(不污染国内仓库)
bash
# 清空全局通用代理
git config --global --unset http.proxy
git config --global --unset https.proxy
# 仅github域名启用代理
git config --global http.https://github.com.proxy http://127.0.0.1:7890
git config --global https.https://github.com.proxy http://127.0.0.1:7890
# 国内镜像自动跳过代理
git config --global http.noProxy ".tuna.tsinghua.edu.cn,.ustc.edu.cn,gitee.com"
3. 生成GitHub SSH密钥(绑定你的邮箱)
bash
ssh-keygen -t ed25519 -C "1617404747@qq.com"
两次回车跳过密钥密码,复制公钥:
bash
pbcopy < ~/.ssh/id_ed25519.pub
粘贴到GitHub网页:头像→Settings→SSH and GPG keys→New SSH key
测试连通:
bash
ssh -T git@github.com
五、常见问题解决
- brew下载一直卡住
确认代理软件7890端口正常运行,终端已执行source ~/.zshrc加载代理环境变量 - MySQL 3306端口被占用
bash
lsof -i :3306
kill -9 进程号
- 忘记MySQL root密码
bash
brew services stop mysql@8.0
mysqld_safe --skip-grant-tables &
mysql -u root
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
exit;
brew services restart mysql@8.0
- Git clone速度只有1-2MB/s
属于代理节点线路拥堵,切换代理节点;也可改用git clone --depth=1浅克隆提速