Solved [SOLVED] MariaDB server service won't start

Just set up a dedicated database jail running databases/mariadb55-server and for some reason it won't start on demand nor on boot.

Any suggestions?

Code:
# service mysql-server start
Starting mysql.
/usr/sbin/daemon: Permission denied
/usr/local/etc/rc.d/mysql-server: WARNING: failed to start mysql

Another question is, why databases/mariadb55-server doesn't respect the /usr/local/etc/my.cnf rather uses /var/db/mysql/something


My environment:
Code:
# env
USER=root
LOGNAME=root
HOME=/root
SHELL=/bin/csh
BLOCKSIZE=K
MAIL=/var/mail/root
MM_CHARSET=UTF-8
LANG=en_US.UTF-8
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
TERM=screen-256color
HOSTTYPE=FreeBSD
VENDOR=amd
OSTYPE=FreeBSD
MACHTYPE=x86_64
SHLVL=1
PWD=/var/db
GROUP=wheel
HOST=db
 
Re: MariaDB server service won't start

pentago said:
Another question is, why databases/mariadb55-server doesn't respect the /usr/local/etc/my.cnf rather uses /var/db/mysql/something
The answer is in the /usr/local/etc/rc.d/mysql-server script.

Code:
: ${mysql_dbdir="/var/db/mysql"}
: ${mysql_optfile="${mysql_dbdir}/my.cnf"}
 
Re: MariaDB server service won't start

Ah, ok but following case of APache, PHP and company, aren't those config files supposed to go to /usr/local/etc?

Any suggestion regarding service startup? Not sure what permissions are being referred to.
 
Re: MariaDB server service won't start

Does the @mysql user and group exist? And are they set up correctly?
 
Last edited by a moderator:
Re: MariaDB server service won't start

I think it's good, at least the way port maintainer intended it to be.
Not sure how to debug this issue exactly..

Code:
root@db ~ # grep mysql /etc/{passwd,group}
/etc/passwd:mysql:*:88:88:MySQL Daemon:/var/db/mysql:/usr/sbin/nologin
/etc/group:mysql:*:88:

Code:
root@db ~ # ls /var/db|grep mysql
drwxr-xr-x   5 mysql     mysql      512B Aug 14 09:46 mysql/

Looks good right?
 
Re: MariaDB server service won't start

Yep, that all looks good. I can't quite find from where /usr/sbin/daemon is launched though. I'm guessing it's part of the whole rc script structure as it's not mentioned in the mysql-server script. Seeing the actual command that's executed may provide some clues. Try starting the script like this: sh -x /usr/local/etc/rc.d/mysql-server start. The sh -x should provide some extra debugging information.
 
Re: MariaDB server service won't start

pentago said:
Does it says anything useful?
At least it shows what it's doing. The offending command is this:
Code:
+ su -m mysql -c 'sh -c "/usr/sbin/daemon  -c -f /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/db/mysql/db.pid "'
/usr/sbin/daemon: Permission denied
It's exactly the same as mine, although I am running mysql55-server.

Did you perhaps set securelevel?
 
Re: MariaDB server service won't start

No, but I mentioned that this is a jailed installation, not sure if that changes anything, I guess not. I want to use it as a dedicated database server for rest of my HTTP jails (though, I considered setting securelevels once I have everything set up to secure it further). Do you have an idea what permissions are problematic? The mysql user can't run /usr/sbin/daemon?
 
Re: MariaDB server service won't start

pentago said:
No, but I mentioned that this is a jailed installation, not sure if that changes anything, I guess not.
No, it doesn't. My MySQL runs in a jail too.

Do you have an idea what permissions are problematic? The mysql user can't run /usr/sbin/daemon?
To be honest I have no idea any more. Everything appears to look in order.
 
OK I resolved the issue. Culprit was setting my /etc/pw.conf umask from 022 to 007 (trying to make it a bit more secure) which resulted in creating basejail's /usr directory with 750 permissions instead of 755 so offending /usr/sbin/daemon couldn't get reached from jail.

Immediately after rebooting the jail service started and works as it supposed to.

I kinda deserve a slap for this mess and I'm sorry. Lesson learned :/
 
Back
Top