macOS 10.15上的Homebrew MySQL 8.0.18 Catalina无法作为服务运行
另一个macOS升级+另一个MySQL升级=另一组问题.
Another macOS upgrade + another MySQL upgrade = another set of problems.
我似乎无法让MySQL 8.0.18作为macOS 10.15 Catalina上的自制程序运行.请告诉我我的方式的错误.
I can't seem to get MySQL 8.0.18 to run as a homebrew service on macOS 10.15 Catalina. Please show me the error of my ways.
这是我所做的:
- 简单安装mysql
- 酿制mysql
- 触摸/tmp/mysql.sock
- mysql.server启动
- 未设置TMPDIR
- mysql_secure_installation
- mysql.server停止
- sudo brew服务启动mysql
这就是我的期望:
MySQL可以作为root用户作为自制服务愉快地运行.
MySQL to run merrily along as a homebrew service as user root.
这是发生了什么:
MySQL崩溃并死亡,在/usr/local/var/mysql/[host.domain.com].err
中留下了一个模糊的最后一个语句:
MySQL falls right over and dies, leaving a cryptic last statement in /usr/local/var/mysql/[host.domain.com].err
:
"[ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!"
其他信息:
只要我手动启动它,MySQL就可以通过随后的重新启动正常运行:
MySQL runs fine through subsequent reboots so long as I launch it manually:
sudo reboot now
ssh [servername.domain.com]
touch /tmp/mysql.sock
mysql.server start
这是/usr/local/var/mysql/[servername.domain.com].err
文件的内容:
2019-10-20T18:02:14.6NZ mysqld_safe Logging to '/usr/local/var/mysql/moriarty.farces.com.err'.
2019-10-20T18:02:14.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
2019-10-20T18:02:14.670494Z 0 [System] [MY-010116] [Server] /usr/local/Cellar/mysql/8.0.18/bin/mysqld (mysqld 8.0.18) starting as process 557
2019-10-20T18:02:14.685511Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2019-10-20T18:02:15.617696Z 0 [System] [MY-010229] [Server] Starting crash recovery...
2019-10-20T18:02:15.626461Z 0 [System] [MY-010232] [Server] Crash recovery finished.
2019-10-20T18:02:15.795626Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-10-20T18:02:15.833541Z 0 [System] [MY-010931] [Server] /usr/local/Cellar/mysql/8.0.18/bin/mysqld: ready for connections. Version: '8.0.18' socket: '/tmp/mysql.sock' port: 3306 Homebrew.
2019-10-20T18:02:15.993739Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/tmp/mysqlx.sock' bind-address: '127.0.0.1' port: 33060
重新启动后,当我尝试将MySQL作为Homebrew服务运行时:
After a reboot, when I try to run MySQL as a Homebrew service:
sudo reboot now
ssh [servername.domain.com]
sudo brew services start mysql
MySQL失败,并在/usr/local/var/mysql/[servername.domain.com].err
文件中记录了以下错误:
MySQL fails with the following error recorded in the /usr/local/var/mysql/[servername.domain.com].err
file:
2019-10-20T18:44:13.780394Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2019-10-20T18:44:13.780503Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-10-20T18:44:13.780727Z 0 [System] [MY-010910] [Server] /usr/local/opt/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.18) Homebrew.
2019-10-20T18:44:13.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/moriarty.farces.com.pid ended
切勿将sudo
与命令brew
一起使用.它将破坏相关文件的所有权.不支持以root用户身份运行brew
.
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
.
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
}
解决方案
-
禁用该服务并删除启动守护程序.
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
最后,大声朗读以下单词:我再也不会将sudo
与brew
一起使用了.
At last, read the following words aloud: I'll never use sudo
with brew
again.