我试图在 Mac (High Sierra) 上运行通过 HomeBrew 安装的 MySQL,但我总是遇到这些权限和 PID 文件问题。我尝试了在网上找到的数百种可能的解决方案,但无法解决这些问题:
Haline:/ Haline$ mysql.server start
Starting MySQL
./usr/local/Cellar/mysql/8.0.12/bin/mysqld_safe: line 144: /usr/local/var/mysql/Haline.local.err: Permission denied
/usr/local/Cellar/mysql/8.0.12/bin/mysqld_safe: line 144: /usr/local/var/mysql/Haline.local.err: Permission denied
/usr/local/Cellar/mysql/8.0.12/bin/mysqld_safe: line 199: /usr/local/var/mysql/Haline.local.err: Permission denied
/usr/local/Cellar/mysql/8.0.12/bin/mysqld_safe: line 144: /usr/local/var/mysql/Haline.local.err: Permission denied
ERROR! The server quit without updating PID file (/usr/local/var/mysql/Haline.local.pid).
有人可以帮助我吗?
根据Homebrew官方故障排除页面:
如果命令因权限错误而失败,请检查 /usr/local 子目录的权限。如果您不确定要做什么,可以运行
。cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var opt Cellar Caskroom Frameworks
或者,如果您尚未在
/usr/local
中安装依赖于特定权限的应用程序,您也可以运行:
sudo chown -R $(whoami) /usr/local/*
我也有同样的问题。以下步骤为我解决了这个问题:
rm -rf /opt/homebrew/var/mysql
uninstall mysql
install mysql
mysql.server start
现在应该可以工作了