且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

macOS 10.15上的Homebrew MySQL 8.0.18 Catalina无法作为服务运行

更新时间:2022-04-19 22:51:01

切勿将sudo与命令brew 一起使用.它将破坏相关文件的所有权.不支持以root用户身份运行brew.

来自Homebrew文档的报价

tl; dr Sudo很危险,您始终没有安装sudo就安装了TextMate.app.

tl;dr Sudo is dangerous, and you installed TextMate.app without sudo anyway.

自制软件拒绝使用sudo工作.

Homebrew refuses to work using sudo.

源代码brew

check-run-command-as-root() {
  ...
  odie <<EOS
Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
EOS
}


解决方案

  1. 禁用该服务并删除启动守护程序.

  1. Disable the service and remove the launchdaemon.

# stop and unload the launchdaemon
sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
# remove the lauchdaemon file
sudo rm -f /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
sudo rm -f /tmp/mysql.sock /tmp/mysqlx.sock

  • 修复/usr/local/

    sudo chown -R "$(whoami):admin" /usr/local/*
    # it will take some time
    

  • 重新启用MySQL服务.

  • Re-enable the MySQL service.

    # DO NOT USE "sudo brew"
    brew services start mysql
    

  • 最后,大声朗读以下单词:我再也不会将sudobrew一起使用了.

  • At last, read the following words aloud: I'll never use sudo with brew again.