2
votes

I am unable to start mysqld via mysql 5.6's mysqld_safe after upgrade to MacOS 10.15 Catalina.

<?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>RunAtLoad</key>         <true/>
    <key>KeepAlive</key>         <true/>
    <key>SessionCreate</key>     <true/>
    <key>LaunchOnlyOnce</key>    <false/>
    <key>ExitTimeOut</key>       <integer>600</integer>
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
    <string>/Users/owenbrunette/bin/mysqld_safe</string>
    </array>
  </dict>
</plist>

The working configuration prior to the 10.15 Catalina upgrade also had the user argument, but I have removed that above, and in further testing, for simplicity as the value of "mysql" is the default user within mysqld_safe.

Working configuration for 10.14 was:

<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<string>--user=mysql</string>
</array>

Both configurations do not work. I have tried initiating as a /bin/sh from the plist. The mysqld_safe is and mysqld are 5.6 as distributed by Apple (mysql-5.6.19-osx10.7-x86_64) and have been on the machine and runnning since OSX 10.7.

I am able to start the server from a terminal as:

export PATH=/usr/bin:/bin:/usr/sbin
sudo /usr/local/mysql/bin/mysqld_safe

which starts a process in the terminal and does not exit (Not to exit is the expected behavior). The process can then be shutdown from another terminal with:

mysqladmin --user=root --password=[MyAdminPassword] shutdown

In the resulting mysqld log I find:

Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

This error indicates that the mysqld was started as the user root rather than as the user mysql. This is contrary to the intentions of mysql_safe, and I think is an important clue. Something may be behaving unexpectedly in msql_safe.

In the system log I find:

... com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system): Session adoption is only allowed in user domains.

This may be fair comment, the mysql_safe script does not exit and remains running until the database server shuts down. This was the same under 10.14 but maybe 10.15 takes a differnt view.

In the Catalina release notes we are told: "Launch daemons and launch agents introduce new user privacy protections" and "launchd property list might not work as expected and prevent the service from running".

4

4 Answers

1
votes

I ran into a similar problem with a bash script I use at startup. My Program key was pointing to the bash script in my User folder, and I see that your ProgramArguments key is also pointing to your User folder. This seems to be one of the things that is no longer allowed (as alluded to in the release notes you quoted), at least not without privilege changes that I wanted to avoid.

The Applications folder does not seem to be restricted in the same way. I moved my bash script to the Applications folder, updated the Program key in the associated plist to point to the new location, restarted, and it worked.

If that doesn't work (or isn't feasible) for your situation, I exchanged a couple of messages with a Redditor who found a different solution: https://www.reddit.com/r/MacOS/comments/dffpzj/launchd_agent_no_longer_functions_after_catalina/f34ykb6/

1
votes

I had the same problem on macOS Mojave 10.14.5. I did the following actions to fix the problem.

Action 1. Delete plist file

cd /Library/LaunchDaemons/
sudo rm homebrew.mxcl.mysql\@5.6.plist

This file is not needed. It is safe to delete this file. Correct file will be created later (in action 3).

Action 2. Restart computer

Maybe it is not necessary. I restarted the computer.

Action 3. Start mysql server

Type following command in console. Do not use sudo (it is important).

brew services start [email protected]

Correct file was created in the following directory.

~/Library/LaunchAgents/

It is

~/Library/LaunchAgents/[email protected]

Action 4. Restart computer again

Maybe it is not necessary. I restarted the computer.

Action 5. Test

Type following command to see that mysql server is running.

brew services list
0
votes

For what it's worth, I hit the same problem and managed to fix it by changing my.cnf to add:

user = mysql

(Previously user was not specified)

This then appears to have fixed the problem so mysql 5.5 automatically starts using the following content in /Library/LaunchDaemons/com.mysql.mysql.plist:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true />
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/mysql/bin/mysqld_safe</string>
      <string>--user=mysql</string>
    </array>        
  </dict>
</plist>

i.e. seems like the key thing was to make sure my.cnf specified the same user as the plist file.

0
votes

A different, but slightly related problem was fixed in my case by:

System Preferences > Security & Privacy > Privacy > Full Disk Access > Terminal > toggle it on.