← home

MySQL in Systemd environment

Aug 05, 2013

After migrating from OpenRC to Systemd on my Gentoo machine, I've faced some troubles with running MySQL in the new environment. The problem was that by default MySQL (which is running under the ‘mysql’ system user) needs the access to /var/run/mysqld/ directory, but /var/run/ is now controlled by systemd, and this directory is created dynamically during every bootup.

The symptoms are:

[ERROR] Can’t start server : Bind on unix socket: No such file or directory
130805 23:19:33 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
130805 23:19:33 [ERROR] Aborting

The solution is:

Description=MySQL Server

ExecStart=/usr/sbin/mysqld –socket=/var/mysql/mysqld.sock –pid-file=/var/mysql/mysql.pid


Creating directory (it should be unreachable for systemd, you know):

# mkdir /var/mysql
# chown mysql:mysql /var/mysql

Staring service:

# systemctl start mysqld

Finally, I wish Lennart Poettering to be burned alive for all of that shit called Systemd.