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
.
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
Originally, whenever I tried mysql.server stop
I would get the error:
ERROR! MySQL server PID file could not be found!
At some point, mysql.server stop
would just hang.
Exploring @sunknudsen's answer, I cd
'ed to the directory:
$ cd /usr/local/bin/
then opened the file:
mysql.server
The code user='mysql'
only appears on one line, so I just commented out that line and replaced it with:
185 #user='mysql'
186 user=`whoami`
Now, this is what happens:
~$ mysql.server start
Starting MariaDB
.200804 15:43:28 mysqld_safe Logging to '/usr/local/var/mysql/My-MacBook-Pro-2.local.err'.
200804 15:43:29 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
SUCCESS!
~$ mysql.server stop
Shutting down MariaDB
. SUCCESS!
~$ mysql.server stop
ERROR! MariaDB server PID file could not be found!
The correct start/stop status is also indicated in System Preferences/MySQL
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With