MariaDB Homebrew 安装错误

12

我刚刚通过homebrew在我的Mac上安装了MariaDB。在安装结束时,我遇到了以下错误:

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall mariadb`
如果我运行brew postinstall mariadb,会得到以下结果:
==> /usr/local/Cellar/mariadb/5.5.34/bin/mysql_install_db --verbose --user=andrew --basedir=/usr/loca
MariaDB is hosted on launchpad; You can find the latest source and
email lists at http://launchpad.net/maria

Please check all of the above before mailing us!  And remember, if
you do mail us, you should use the /usr/local/Cellar/mariadb/5.5.34/scripts/mysqlbug script!

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

这并没有什么帮助!我正在跟随教程运行unset TEMPDIRmysql_install_db --user=mysql --basedir=$(brew --prefix mariadb)命令,但是结果如下:

/usr/local/opt/mariadb/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2)
Fatal error in defaults handling. Program aborted
chown: ./data: Operation not permitted
Cannot change ownership of the database directories to the 'mysql'
user.  Check that you have the necessary permissions and try again.
我怀疑问题与 /usr/local/etc/my.cnf.d 文件夹有关。在我尝试的一些方法中,我看到了这个文件夹的提及,但是它在我的机器上不存在。我尝试了其他一些教程中找到的不同的 mysql_install_db 命令,但是他们都报错了(错误信息各不相同)。 谢谢任何帮助!
8个回答

阿里云服务器只需要99元/年,新老用户同享,点击查看详情
29

打开编辑器,找到配置文件 /usr/local/etc/my.cnf 并注释掉以下这行代码:

!includedir /usr/local/etc/my.cnf.d

1
这是我选择的解决方案。每次在“brew prune”之后添加“/usr/local/etc/my.cnf.d”似乎太脆弱了,而且我很可能会忘记它在将来出现错误时。注释掉那行似乎是最好的解决方案。 - Dave Everitt
我刚刚注释掉了那一行,然后它就可以运行了,谢谢。 - Ricardo Lucas

18

在进一步搜索问题无果后,我尝试手动创建了一个 /usr/local/etc/my.cnf.d 文件夹,现在 mysql_install_db 命令似乎已经可以正常工作了。我不确定这是否是适当的解决方案,或者 my.cnf.d 不存在是否表明安装存在更深层次的问题,但是由于事情似乎正在运行,我将其标记为已解决。

[更新] 我不太确定我的答案是否是“正确”的解决方案,所以我想确认一下,一个月后,一切仍然正常运行。


1
谢谢提供信息。虽然我也不理解,但创建这个文件夹确实也解决了我的问题。 - laurent
3
这个方法完全可行,但需要小心,因为brew prune会删除/usr/local/etc/my.cnf.d。解决方法是在执行brew prune之后手动替换它,只是想提醒一下。 - Michael Thompson

6

这里提供的解决方案都没有帮助,我只能按以下步骤操作才成功:

The post-install step did not complete successfully MySQL Mac OS Sierra

简要来说,

  • 我备份了文件夹 /usr/local/var/mysql ,然后将其删除
  • 删除 Mariadb: brew remove mariadb
  • 重新安装 Mariadb: brew install mariadb
  • 运行: brew services start mariadb

之后就可以使用 mysql -u root 访问了。


在MacOS Mojave 10.14中工作过。 - Machado

4
您可能有一份孤立的配置文件。我通过删除旧的 /usr/local/etc/my.cnf 文件来解决了这个问题。您的情况可能有所不同。

3

如果您在2021年遇到此问题

以下方法对我有效:

sudo mysql_install_db
sudo chown -R <YOUR USER NAME HERE> /usr/local/mysql # for example sudo chown -R jperez /usr/mysql
sudo chgrp -R admin /usr/local/mysql

之后,运行mysqlmariadb将显示数据库提示符。


2

这个问题最近似乎已经解决了。

对我来说,一个简单的bew upgrade就解决了这个问题。


0
对于那些在2023年仍然遇到此问题的人: 找到并删除my.cnf文件,我的文件位于/opt/homebrew/etc目录下。
find . -name "my.cnf" -exec rm -i {} \;
或者更加谨慎一些。
find . -name my.cnf
手动删除my.cnf文件。
brew postinstall mariadb

0

你可能想要去

/usr/local/mysql

删除旧的MySQL文件并重新安装


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,