我安装了(因为我需要它们)mysql(因此8.0)和[email protected]通过带有 Ventura 13.3.1 的 MBP Apple M2 上的 Homebrew 程序
我正确设置了(第一个)mysql 安装;
现在我切换到[email protected] :首先我注意到它没有安装正确的数据库(或者它使用与其他公式相同的数据库...?!!)并经历了臭名昭著的错误2002(HY000):无法连接到本地MySQL通过 brew services restart <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aac7d3d9dbc6ea9f849d" rel="noreferrer noopener nofollow">[email protected]</a>
设置服务后,通过套接字 '/tmp/mysql.sock' (2) 服务器
问题:似乎启动文件的命名不同,但某些参数设置相同(datadir 和 WorkingDirectory);那么我可以安全地改变这些吗...? (我还注意到,每次我通过 brew services stop xxx
停止每个服务时,相应的文件都会被删除!所以它一定来自某个地方......?)
基本上我想要像 /opt/homebrew/var/[email protected] 这样的东西 对于 5.7 版本;那我该怎么办? (尤其是我也需要为 5.7 建立一个新的数据库......)
由于我对这个领域很陌生,所以我开始在这里浏览各种主题,例如https://superuser.com/questions/1333504/brew-install-mysql5-7-cant-connect-to-local-mysql-server-through-socket brew start and brew restart wont start service和其他一些,并且不可避免地最终会建议完全清除与 mysql 相关的所有内容并仅重新安装 1 个版本(这不是我想要的)。
对于mysql
:
me@localhost ~ % more ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql</string>
<key>LimitLoadToSessionType</key>
<array>
<string>Aqua</string>
<string>Background</string>
<string>LoginWindow</string>
<string>StandardIO</string>
<string>System</string>
</array>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/opt/mysql/bin/mysqld_safe</string>
<string>--datadir=/opt/homebrew/var/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/homebrew/var/mysql</string>
</dict>
</plist>
对于<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="deb3a7adafb29eebf0e9" rel="noreferrer noopener nofollow">[email protected]</a>
:
me@localhost ~ % more ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
/Users/me/Library/LaunchAgents/homebrew.mxcl.mysql.plist: No such file or directory
me@localhost ~ % more ~/Library/LaunchAgents/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="630b0c0e06011106144d0e1b000f4d0e1a10120f23564d544d130f0a1017" rel="noreferrer noopener nofollow">[email protected]</a>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string><a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8be3e4e6eee9f9eefca5e6f3e8e7a5e6f2f8fae7cbbea5bc" rel="noreferrer noopener nofollow">[email protected]</a></string>
<key>LimitLoadToSessionType</key>
<array>
<string>Aqua</string>
<string>Background</string>
<string>LoginWindow</string>
<string>StandardIO</string>
<string>System</string>
</array>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/opt/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="94f9ede7e5f8d4a1baa3" rel="noreferrer noopener nofollow">[email protected]</a>/bin/mysqld_safe</string>
<string>--datadir=/opt/homebrew/var/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/homebrew/var/mysql</string>
</dict>
</plist>
PS:当我修改上述文件时,启动服务失败(顺便说一句,文件被覆盖......):
me@localhost ~ % brew services start <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec81959f9d80acd9c2db" rel="noreferrer noopener nofollow">[email protected]</a>
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/503 /Users/me/Library/LaunchAgents/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ee6e1e3ebecfcebf9a0e3f6ede2a0e3f7fdffe2cebba0b9a0fee2e7fdfa" rel="noreferrer noopener nofollow">[email protected]</a>` exited with 5.
最佳答案
只是使用 Homebrew 设置多个 MySQL 实例的见解 - 它会在每次 brew 更新
时切换您以前的 plist/服务配置文件。
因此,当您有一个可用的 5.7 + 8.0 版本并带有自定义配置文件时,brew mysql 更新会将配置重新链接到新配置(回退到默认值并忽略配置)。
因此,如果您将 datadir 设置为 /var/mysql_57
和 /var/mysql_80
,它将回退到从 /var/mysql 加载文件/
。因此,强烈建议对这两个版本使用非默认数据目录。
在运行brew升级时考虑这一点,并在再次运行SQL实例之前编辑新配置。
注意:实际上,我遇到了与您 atm 相同的错误。在最新升级到 5.7.43
之前它运行良好,现在它忽略我的设置并将核心 MySQL 数据和 InnoDB 文件与 SQL 表数据一起放入 datadir
中默认WorkingDirectory
的。使用 CLI 参数从控制台执行命令与使用 Homebrew 服务运行实例之间的命令执行似乎有所不同(我多年来一直使用相同配置,但不再像我预期的那样工作)。从 CLI 运行 5.7 实例工作正常,但 brew 服务失败。
注2:其他brew软件包从来没有遇到过这样的问题,不得不艰难地学习MySQL......
当我弄清楚出了什么问题时,我会回到这里。如果您需要配置提示,请告诉我。
关于mysql - 如何让 Homebrew 安装的mysql和mysql@5.7独立工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76074498/