Homebrew 速查表

Homebrew 速查表

January 7, 2020
速查表
★ 在 GitHub 赞我

Homebrew 是 macOS 上的软件包管理器。


安装 Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

在运行 brew install, brew upgradebrew tap 前跳过自动更新:

export HOMEBREW_NO_AUTO_UPDATE=1

使用 macOS 的 launchctl 管理后台程序:

brew services start mysql
brew services run mysql
brew services stop mysql
brew services restart mysql
brew services list # List all services managed by brew services with
brew services cleanup # Remove all unused services with:

安装没有 GUI 的软件:

brew install [name]
brew uninstall [name]
brew upgrade [name]

安装有 GUI 的软件:

brew cask install DeepL
brew cask uninstall DeepL

安装 Java:

brew cask install java # openjdk 最新版
brew cask install homebrew/cask-versions/zulu8 # jdk8

安装 Redis:

brew install redis
brew services start redis
redis-cli
brew services stop redis

安装 PostgreSQL:

brew install postgresql
brew postgresql-upgrade-database # 迁移数据
brew services start postgresql
brew services stop postgresql

安装 MongoDB:

brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
brew services stop mongodb-community
# /usr/local/etc/mongod.conf

修改 Homebrew 源:

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

重置 Homebrew 源:

cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
// homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

修改 Homebrew Bottles 源:

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

备注:中国大陆安装 Homebrew 可能有困难,可参考:这里 加速安装