Topic: MySQL 5.5.9-1.el6.x86_64 init script does not start on custom data dir

As the subject implies, I cannot start the mysql daemon using the init script using a custom data directory /mnt/drbd/mysql/data. The magical thing about this issue is that I can start the daemon using the exact mysqld_safe command that the script executes. Also, the init script works fine on the default data dir. I can also stop the daemon, even with my custom datadir, using the init script.

Environment: RHEL 6 amd64 mysql 5.5.9-1 datadir=/mnt/drbd/mysql/data

Re: MySQL 5.5.9-1.el6.x86_64 init script does not start on custom data dir

I d'ont see any issue with the init script.

Which errors are raised during startup ?

I think of a SElinux protection.
Try to temprorary disable SElinux (setenforce 0), read the audit.log, check the security context of your datadir (ls -aZ /mnt/drbd/mysql/data)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: MySQL 5.5.9-1.el6.x86_64 init script does not start on custom data dir

Thanks Remi, setenforce works

Here's the magic just in case you're interested:

mysql is supposed to start with the following command:

/usr/bin/mysqld_safe --datadir=/mnt/drbd/mysql/data --socket=/tmp/mysql.sock --pid-file=/var/run/mysqld/mysqld/pid --basedir=/usr --user=mysql >/dev/null 2>&1 &

Then the script enters a loop to ping the mysqld_safe process:

/usr/bin/mysqladmin --socket=/tmp.mysql.sock --user=UNKNOWN_MYSQL_USER ping 2>&1 &

The ping response is the following:

/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL through socket '/tmp/mysql.sock' (2)'

if I execute the the mysqld_safe command manually and ping manually also, everything works, even with selinux enforcement. Now with setenforce 0 the init scripts executes fine. So all I have left is to figure out how to configure SELinux so that everything works and the appropriate services are started on reboot.

Re: MySQL 5.5.9-1.el6.x86_64 init script does not start on custom data dir

So solution is probably proposed on the AVC denied recorded in the audit.log.


+

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi