问题
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