Permissions problem starting mariadb

General support questions
Post Reply
gw1500se
Posts: 222
Joined: 2012/05/07 13:53:35

Permissions problem starting mariadb

Post by gw1500se » 2014/12/30 14:00:15

I've just installed mariadb and it fails out of the box:

Code: Select all

Dec 30 08:52:46 dap004.dap.localnet mysqld_safe[3650]: /usr/bin/mysqld_safe: line 182: /var/log/mysqld.log: Permission denied
Dec 30 08:52:46 dap004.dap.localnet mysqld_safe[3650]: touch: cannot touch ‘/var/log/mysqld.log’: Permission denied
Dec 30 08:52:46 dap004.dap.localnet mysqld_safe[3650]: chown: cannot access ‘/var/log/mysqld.log’: Permission denied
Dec 30 08:52:46 dap004.dap.localnet mysqld_safe[3650]: chmod: cannot access ‘/var/log/mysqld.log’: Permission denied
Dec 30 08:52:46 dap004.dap.localnet mysqld_safe[3650]: 141230 08:52:46 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Dec 30 08:52:46 dap004.dap.localnet mysqld_safe[3650]: /usr/bin/mysqld_safe: line 138: /var/log/mysqld.log: Permission denied
Dec 30 08:52:46 dap004.dap.localnet systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Dec 30 08:52:47 dap004.dap.localnet systemd[1]: mariadb.service: control process exited, code=exited status=1
Dec 30 08:52:47 dap004.dap.localnet systemd[1]: Failed to start MariaDB database server.
Dec 30 08:52:47 dap004.dap.localnet systemd[1]: Unit mariadb.service entered failed state.
[root@dap004 ~]# ls -l /var/log/mysqld.log
-rw-r--r-- 1 mysql mysql 0 Dec 30 08:43 /var/log/mysqld.log
While it seems like the installer should handle setting up permissions, it apparently does not. I manually changed permissions but it does not help. It makes no sense that the run user (mysql) cannot write to files it owns. Can someone tell me what is going on here? Here is my.conf, just in case:

Code: Select all

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
I originally had a permissions error on /var/lib/mysql as well but a chown on that seemed to work. TIA.

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Permissions problem starting mariadb

Post by avij » 2014/12/30 14:33:57

Which version of MariaDB are you using? What does rpm -q mariadb-server output?

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Permissions problem starting mariadb

Post by aks » 2014/12/30 17:58:07

This is probably an selinux problem. Just try running it in permissive mode (not long term nor in production mind!)

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Permissions problem starting mariadb

Post by avij » 2014/12/30 18:37:59

Indeed. If you are using the stock MariaDB as provided by CentOS, using the following might help as there are existing SELinux policies for these files and directories:

Code: Select all

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

gw1500se
Posts: 222
Joined: 2012/05/07 13:53:35

Re: Permissions problem starting mariadb

Post by gw1500se » 2014/12/31 02:33:53

Thanks to all for the replies.

avij: This is the version that came off the everything ISO: mariadb-server-5.5.35-3.el7.x86_64

aks: This is not a selinux issue as it is currently disabled.

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Permissions problem starting mariadb

Post by avij » 2014/12/31 07:41:54

There's already a 5.5.40, yum update should give you that.

The default /etc/my.cnf has this useful piece of information:
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
MariaDB does run out of the box (as in, unmodified /etc/my.cnf). Things may start breaking if user names or file names are changed from the defaults.

That said, mysql is the default user for MariaDB, and your configuration should work. I wonder if there are conflicting entries for the mysql user in /etc/passwd ?

Code: Select all

# grep mysql /etc/passwd
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin

gw1500se
Posts: 222
Joined: 2012/05/07 13:53:35

Re: Permissions problem starting mariadb

Post by gw1500se » 2015/01/01 13:58:07

The mysql user is identical to yours and there is only 1 entry. However, I was trying to change the names of the log file because I have a number of scripts that depend on it so that should be easier than changing all the scripts(this is a kickstart install on a new server). I'll leave the my.cnf file alone to see if that resolves it. Unfortunately I've run into another odd problem, which is a different thread, that I need to resolved first. Thanks.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Permissions problem starting mariadb

Post by aks » 2015/01/02 18:07:07

Please post the output of your database error log (so cat $(grep log-err /etc/my.cnf | sed s/'^log.*='/''/) unless you're using additional configurations in /etc/my.cnf.d/).

gw1500se
Posts: 222
Joined: 2012/05/07 13:53:35

Re: Permissions problem starting mariadb

Post by gw1500se » 2015/01/04 17:52:35

I think the problem is trying to start mariadb in the %post section of a kickstart file. I want to mysqldump the databases from the old server to the new one. Perhaps that is not necessary and simply copying the /var/lib/mysql files is sufficient but I was not sure the formats are compatible so I figured using mysqldump across the LAN would be better. So the question becomes how can I start mariadb in the kickstart file or is just copying the mysql directory safe?

Trying to use 'systemctl start mariadb.service' in the kickstart fails:

In chroot, command ignored

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Permissions problem starting mariadb

Post by aks » 2015/01/05 19:44:35

So yes and no (not the answer you want).

If you're only using MyISAM then yes, probably. You could loose a few rows, but MyISAM is not ACID compliant - it's actually very, very simple. If you're using InnoDB (or just about any of the other persistant engines), then possibly. For InnoDB you probably need to copy the double write buffer(s), data dictionar(ies) and logs. The source MySQL should NOT be running because you do not know what data is still held in memory and has not been flushed to disk at the point of the copy (although you can execute a flush command, in the time it takes to flush some new transactions could arrive and with something that is forgein key aware engines (like InnoDB) that could result in the transaction being rejected - depending....)

So yes and no......

Also the %post thing can log the output (to screen) so ensure you switch warnings on in MySQL/MariaDB - as some (what may be quite important bits to the application) could fail in a warning situation, which the DB does nto consider important, but the applicaiton may. If you have warning on, then you would know of them, but by default you won't.

Post Reply