CyanHall.com 创建于 2020-11-10, 上次更新:2021-04-30。
👉  github shields 如果有用请点赞。
Homebrew 是 macOS 上的软件包管理器。

1. 安装 Homebrew

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

# for x86_64
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
alias ibrew="arch -x86_64 /usr/local/bin/brew" # save in .zshrc
ibrew install [email protected]
  

2. 在运行 brew install/upgrade/tap 前跳过自动更新

    export HOMEBREW_NO_AUTO_UPDATE=1
  

3. 使用 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
  

4. 安装没有图形界面的软件

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

5. 安装有图形界面的软件

    brew cask install DeepL
brew cask uninstall DeepL
  

6. Uninstall any applications using Homebrew

    # include third party application installed not using Homebrew.
brew uninstall --cask --force --zap pycharm
# --zap will delete relative files, can be checked with: brew cat
  

7. 安装 Java

    brew cask install java # latest openjdk version
brew cask install homebrew/cask-versions/zulu8 # jdk8
  

8. 安装 Redis

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

9. 安装 PostgreSQL

    brew install postgresql
brew postgresql-upgrade-database # migrate existing data
brew services start postgresql
brew services stop postgresql
# /opt/homebrew/opt/postgresql/bin/postgres -D /opt/homebrew/var/postgres
# // echo 'export PATH="/opt/homebrew/opt/postgresql@13/bin:$PATH"' >> ~/.zshrc
# export LDFLAGS="-L/opt/homebrew/opt/postgresql@13/lib"
# export CPPFLAGS="-I/opt/homebrew/opt/postgresql@13/include"
  

10. Install MySQL

    brew install mysql
brew services start mysql
brew services stop mysql
# /opt/homebrew/opt/mysql/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql
# sudo /opt/homebrew/Cellar/mysql/8.0.28/bin/mysql.server start
  

11. 安装 MongoDB

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

12. brew reinstall [email protected]

    A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/[email protected]/certs

and run
  /usr/local/opt/[email protected]/bin/c_rehash
  
[email protected] is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
  

13. 修改 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
  

14. 重置 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
  

15. 修改 Homebrew Bottles 源

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

1. 安装 Homebrew

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

# for x86_64
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
alias ibrew="arch -x86_64 /usr/local/bin/brew" # save in .zshrc
ibrew install [email protected]
  

3. 使用 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
  

5. 安装有图形界面的软件

    brew cask install DeepL
brew cask uninstall DeepL
  

7. 安装 Java

    brew cask install java # latest openjdk version
brew cask install homebrew/cask-versions/zulu8 # jdk8
  

9. 安装 PostgreSQL

    brew install postgresql
brew postgresql-upgrade-database # migrate existing data
brew services start postgresql
brew services stop postgresql
# /opt/homebrew/opt/postgresql/bin/postgres -D /opt/homebrew/var/postgres
# // echo 'export PATH="/opt/homebrew/opt/postgresql@13/bin:$PATH"' >> ~/.zshrc
# export LDFLAGS="-L/opt/homebrew/opt/postgresql@13/lib"
# export CPPFLAGS="-I/opt/homebrew/opt/postgresql@13/include"
  

11. 安装 MongoDB

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

13. 修改 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
  

15. 修改 Homebrew Bottles 源

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

2. 在运行 brew install/upgrade/tap 前跳过自动更新

    export HOMEBREW_NO_AUTO_UPDATE=1
  

4. 安装没有图形界面的软件

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

6. Uninstall any applications using Homebrew

    # include third party application installed not using Homebrew.
brew uninstall --cask --force --zap pycharm
# --zap will delete relative files, can be checked with: brew cat
  

8. 安装 Redis

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

10. Install MySQL

    brew install mysql
brew services start mysql
brew services stop mysql
# /opt/homebrew/opt/mysql/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql
# sudo /opt/homebrew/Cellar/mysql/8.0.28/bin/mysql.server start
  

12. brew reinstall [email protected]

    A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/[email protected]/certs

and run
  /usr/local/opt/[email protected]/bin/c_rehash
  
[email protected] is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
  

14. 重置 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
  


Maitained by Cyanhall.com, Copy Rights @ CC BY-NC-SA 4.0