How can I fix brew-installed MariaDB that hangs on `mysql.server stop` and doesn’t stop?

扶醉桌前 提交于 2020-03-03 07:36:40

问题


This question is not a duplicate of mariadb server: I can't stop the server with `mysql.server stop`.

I don’t want to run MariaDB at boot so brew services isn’t an option.

MariaDB version is 10.4.11-MariaDB.


回答1:


Think I found the culprit.

Having a look at the source code of mysql.server (cat /usr/local/bin/mysql.server), I discovered that running mysql.server start runs mysqld_safe as me (whoami) which is what I expected.

Now, I also discovered that running mysql.server stop runs a su_kill function that runs su as mysql which fails because the mysql user doesn’t exist on macOS.

user='mysql'

su_kill() {
  if test "$USER" = "$user"; then
    kill $* >/dev/null 2>&1
  else
    su - $user -s /bin/sh -c "kill $*" >/dev/null 2>&1
  fi
}

Not sure if I am doing something wrong, but according to the documentation, running mysql.server start is the right way of starting MariaDB on brew installs.

Anyhow, to patch mysql.server stop, run:

cp /usr/local/bin/mysql.server /usr/local/bin/mysql.server.backup
sed -i "" "s/user='mysql'/user=\`whoami\`/g" /usr/local/bin/mysql.server


来源:https://stackoverflow.com/questions/59936589/how-can-i-fix-brew-installed-mariadb-that-hangs-on-mysql-server-stop-and-doesn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!