Change MySQL (mariadb) daemon user

Hello,

Sorry if my question may sound silly or has already been dealt with elsewhere, but I'm brand new on this forum and did not found any answer despite a few searches...

The question, however, is quite simple : I just installed MariaDB server (I think the problem would be similar with MySQL, but did not checked that), it seems to work fine, but I would-like to start it using another account than the default "mysql" one.

However, I did not find a clean way to do that, since it seems to me that this default account is hardcoded in the /usr/local/etc/rc.d/mysql-server script:
Code:
: ${mysql_enable="NO"}
: ${mysql_limits="NO"}
: ${mysql_dbdir="/var/db/mysql"}

mysql_user="mysql"

As background information, I'm setting a few DB servers running in different jails on the same physical machine, but I prefer to avoid having several processes sharing the same UIDs among the jails. Since they are unrelated to each other,I prefer it is clearly stated by affecting a unique UID to each one. Trivial task for most of services, however I'm stuck with MariaDB.
I would have thought of a mysql_user parameter settable in the /etc/rc.conf file before starting the service and manually launch mysql_install_d --user=<my-new-user> afterward, but something different seem to be awaited and I do not know what...

Maybe some option to set when installing the package in the jail (I guess the fact the user is hardcoded is due to ownership of the installed data files)? I hope I'm not supposed to recompile the complete database server each time I want to use a different account to launch it? Same way I prefer no to drop or alter rc.d startup script - all this does not seem clean to me...

Thank you by advance for your help and advices!
Regards,
Gzbk.
 
gzbk said:
However, I did not find a clean way to do that, since it seems to me that this default account is hardcoded in the /usr/local/etc/rc.d/mysql-server script:
Code:
: ${mysql_enable="NO"}
: ${mysql_limits="NO"}
: ${mysql_dbdir="/var/db/mysql"}

mysql_user="mysql"

Change that last line to something like this:
Code:
: ${mysql_user="mysql"}
You can then use mysql_user in /etc/rc.conf. If it's not set it'll use mysql by default.

Keep in mind you'll also need to change the ownership of the various files and directories.
 
Back
Top