MAC OS brew的使用

brew 是 Mac 下的一个包管理工具,类似于 centos 下的 yum,可以很方便地进行安装/卸载/更新各种软件包,例如:nodejs, elasticsearch, kibana, mysql, mongodb 等等,可以用来快速搭建各种本地环境,程序员必备工具

安装 brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装/卸载/更新

以 nodejs 为例,执行下面命令即可,安装目录在 /usr/local/Cellar

brew install nodejs

如果需要更新或卸载

brew upgrade nodejs
brew remove nodejs

 

brew list                   # 列出当前安装的软件
brew search nodejs          # 查询与 nodejs 相关的可用软件
brew info nodejs            # 查询 nodejs 的安装信息

如果需要指定版本,可以在 brew search 查看有没有需要的版本,在 @ 后面指定版本号,例如 brew install thrift@0.9

brew services

brew services 是一个非常强大的工具,可以用来管理各种服务的启停,有点像 linux 里面的 services,非常方便,以 elasticsearch 为例

brew install elasticsearch          # 安装 elasticsearch
brew services start elasticsearch   # 启动 elasticsearch
brew services stop elasticsearch    # 停止 elasticsearch
brew services restart elasticsearch # 重启 elasticsearch
brew services list                  # 列出当前的状态

 

brew services 服务相关配置以及日志路径

  • 配置路径:/usr/local/etc/
  • 日志路径:/usr/local/var/log

 

安装mysql:

brew install mysql

 

We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.18_1: 287 files, 278.6MB
==> 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 openssl/libressl is provided by macOS so don't link an incompatible version.

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"

==> protobuf@3.7
protobuf@3.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

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

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

==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start

 

mysql.server stop

 

 

参考链接

 

posted @ 2019-12-01 17:29  Practical  阅读(968)  评论(0编辑  收藏  举报