On Mac, MySQL seems to save data as the "_mysql" user. Can somebody please explain how this is achieved. I would have expected the MySQL server application (mysqld) to have the setuid flag set, so that it would run as _mysql, but this isn't the case. How, then, does it somehow run as "_mysql"?
Asked
Active
Viewed 3,680 times
1 Answers
1
There's a wide variety of ways this can be accomplished, but the two most common are:
- Processes started as root can change their user id to any other user on the system through their own internal programming; most daemons including MySQL operate this way.
- Processes can be started with
sudo -u _mysql mysqld
or it's rough equivalent.

Chris S
- 77,945
- 11
- 124
- 216
-
Thanks Chris. In relation to (1), would this be through system-specific APIs? I'm wondering how you go about this in C or Java. – visitor93746 Aug 25 '10 at 20:53
-
1setuid() and friends in C – James Aug 25 '10 at 22:28
-
Directions for calling setuid() from Java: http://www2.sys-con.com/itsg/virtualcd/Java/archives/0510/Silverman/index.html – Chris S Aug 25 '10 at 22:33