0

I have issues starting a MariaDB service on a Centos 7 server, because the directory /var/run/mysqld/ is not created by default, as well as the /var/log/mysqld.log file.

Creating this directory and file with the correct permissions allow MariaDB to start properly, but on reboot, the directory is deleted and has to be recreated.

/etc/systemd/system/multi-user.target.wants/mariadb.service will start the script when running service mariadb start; according to that file, on start it execute /usr/libexec/mariadb-prepare-db-dir, where I have added the following:

touch /var/log/mysqld.log                
chown mysql:mysql /var/log/mysqld.log
mkdir /var/run/mysqld                    
chown mysql:mysql /var/run/mysqld        

The log file is properly created, but not the directory. Why ? How can I create it properly, when the service is started ? I thought about a permission problem, but I do not know where to find more information.

The mariadb is installed directly via yum, and it's version 5.5. Why it's not functional out of the box is beyond me.

user96649
  • 121

2 Answers2

1

Actually, Mairadb locate pid file in /var/run/mariadb.
Then,you needn't any other operation just set pid-file=/var/run/mariadb/mysqld.pid

kittygirl
  • 1,025
  • 5
  • 18
  • 36
0

I had a similar problem recently. My workaround was to add it to crontab as root:

$ crontab -e

add:

@reboot mkdir /var/run/mysqld && chown mysql:mysql /var/run/mysqld

There might be better locations to create the directory at startup, but for me this works.

Gerald Schneider
  • 26,582
  • 8
  • 65
  • 97