MacOS 安装 brew (国内镜像源)

MacOS 安装 brew (国内镜像源)

安装命令:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

安装过程:

bright@MacOS10-15 ~ % /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

               开始执行Brew自动安装程序 
              [cunkai.wang@foxmail.com] 
           ['2021-03-14 10:50:01']['10.15']
        https://zhuanlan.zhihu.com/p/111014448 


请选择一个下载镜像,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。cask非必须,有部分人需要。
1、中科大下载源 2、清华大学下载源 3、北京外国语大学下载源  4、腾讯下载源(不显示下载进度) 5、阿里巴巴下载源(缺少cask源)  

请输入序号: 2


    你选择了清华大学下载源
    
!!!此脚本将要删除之前的brew(包括它下载的软件),请自行备份。
->是否现在开始执行脚本(N/Y) y

--> 脚本开始执行
 Mac os设置开机密码方法:
  (设置开机密码:在左上角苹果图标->系统偏好设置->用户与群组->更改密码)
  (如果提示This incident will be reported. 在用户与群组中查看是否管理员) 
==> 通过命令删除之前的brew、创建一个新的Homebrew文件夹
请输入开机密码,输入过程不显示,输入完后回车
Password:
开始执行
-> 创建文件夹 /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/Homebrew
此步骤成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown bright /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew
git version 2.24.3 (Apple Git-128)

下载速度觉得慢可以ctrl+c或control+c重新运行脚本选择下载源
==> 克隆Homebrew基本文件

未发现Git代理(属于正常状态)
Cloning into '/usr/local/Homebrew'...
remote: Counting objects: 176534, done.
remote: Compressing objects: 100% (45695/45695), done.
remote: Total 176534 (delta 131118), reused 170993 (delta 126786)
Receiving objects: 100% (176534/176534), 44.47 MiB | 827.00 KiB/s, done.
Resolving deltas: 100% (131118/131118), done.
此步骤成功
--创建Brew所需要的目录
运行代码 ==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/lib
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/lib
运行代码 ==> /usr/bin/sudo /usr/sbin/chown bright /usr/local/bin /usr/local/lib
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/lib
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/etc /usr/local/include /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/etc /usr/local/include /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks
运行代码 ==> /usr/bin/sudo /usr/sbin/chown bright /usr/local/etc /usr/local/include /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/etc /usr/local/include /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R bright:admin /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /Users/bright/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /Users/bright/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R bright /Users/bright/Library/Caches/Homebrew
--依赖目录脚本运行完成
==> 创建brew的替身
==> 克隆Homebrew Core
此处如果显示Password表示需要再次输入开机密码,输入完后回车
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 925474, done.
remote: Compressing objects: 100% (310177/310177), done.
remote: Total 925474 (delta 631263), reused 899804 (delta 612202)
Receiving objects: 100% (925474/925474), 284.73 MiB | 841.00 KiB/s, done.
Resolving deltas: 100% (631263/631263), done.
Updating files: 100% (5817/5817), done.
此步骤成功
==> 克隆Homebrew Cask 图形化软件
  此处如果显示Password表示需要再次输入开机密码,输入完后回车
Password:
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Counting objects: 553943, done.
remote: Compressing objects: 100% (167904/167904), done.
remote: Total 553943 (delta 392489), reused 544497 (delta 384515)
Receiving objects: 100% (553943/553943), 231.37 MiB | 946.00 KiB/s, done.
Resolving deltas: 100% (392489/392489), done.
Updating files: 100% (3946/3946), done.
此步骤成功
==> 配置国内镜像源HOMEBREW BOTTLE
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /Users/bright/.zprofile
Password:
运行代码 ==> /usr/bin/sudo /usr/sbin/chown bright /Users/bright/.zprofile
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /Users/bright/.zprofile
环境变量写入->/Users/bright/.zprofile
此步骤成功
电脑系统版本:10.15
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown bright /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew

==> 安装完成,brew版本

Homebrew 3.0.5-42-ge3b451c-dirty
Homebrew/homebrew-core (git revision 77a0f2c34f; last commit 2021-03-13)
Homebrew/homebrew-cask (git revision 32acfc7e77; last commit 2021-03-14)
Brew前期配置成功

==> brew update

==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
######################################################################### 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
Already up-to-date.

        Brew自动安装程序运行完成
          国内地址已经配置完成

  桌面的Old_Homebrew文件夹,大致看看没有你需要的可以删除。

              初步介绍几个brew命令
本地软件库列表:brew ls
查找软件:brew search google(其中google替换为要查找的关键字)
查看brew版本:brew -v  更新brew版本:brew update
安装cask软件:brew install --cask firefox 把firefox换成你要安装的
        
        欢迎右键点击下方地址-打开URL 来给点个赞
         https://zhuanlan.zhihu.com/p/111014448 

 重启终端 或者 运行 source /Users/bright/.zprofile  ,否则可能无法使用
  
bright@MacOS10-15 ~ % source .zprofile 
bright@MacOS10-15 ~ % brew
Example usage:
  brew search [TEXT|/REGEX/]
  brew info [FORMULA...]
  brew install FORMULA...
  brew update
  brew upgrade [FORMULA...]
  brew uninstall FORMULA...
  brew list [FORMULA...]

Troubleshooting:
  brew config
  brew doctor
  brew install --verbose --debug FORMULA

Contributing:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew
  https://docs.brew.sh
bright@MacOS10-15 ~ % brew list
bright@MacOS10-15 ~ % brew config
HOMEBREW_VERSION: 3.0.5-42-ge3b451c-dirty
ORIGIN: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
HEAD: e3b451cce8b555da5c4043767fe1659d14d04264
Last commit: 7 hours ago
Core tap ORIGIN: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
Core tap HEAD: 77a0f2c34f197a45e42c9ed54960c2ce29adbc23
Core tap last commit: 4 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_BOTTLE_DOMAIN: https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 4
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/bin/ruby
CPU: quad-core 64-bit skylake
Clang: 12.0 build 1200
Git: 2.24.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 10.15.7-x86_64
CLT: 12.4.0.0.1.1610135815
Xcode: N/A
bright@MacOS10-15 ~ % brew install mysql-client
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/op
######################################################################## 100.0%
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/my
######################################################################## 100.0%
==> Installing dependencies for mysql-client: openssl@1.1
==> Installing mysql-client dependency: openssl@1.1
==> Pouring openssl@1.1-1.1.1j.catalina.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.1j: 8,071 files, 18.5MB
==> Installing mysql-client
==> Pouring mysql-client-8.0.23.catalina.bottle.tar.gz
==> Caveats
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because it conflicts with mysql (which contains client libraries).

If you need to have mysql-client first in your PATH, run:
  echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql-client/include"

==> Summary
🍺  /usr/local/Cellar/mysql-client/8.0.23: 135 files, 151.0MB
==> Caveats
==> openssl@1.1
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

==> mysql-client
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because it conflicts with mysql (which contains client libraries).

If you need to have mysql-client first in your PATH, run:
  echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql-client/include"

bright@MacOS10-15 ~ % 

Install MySQL and mysqlclient:

# Assume you are activating Python 3 venv
$ brew install mysql
$ pip3 install mysqlclient

If you don’t want to install MySQL server, you can use mysql-client instead:

# Assume you are activating Python 3 venv
$ brew install mysql-client
$ echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
$ export PATH="/usr/local/opt/mysql-client/bin:$PATH"
$ pip3 install mysqlclient
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值