I really don't understand how all those privileges work in Linuxes.
To start MySQL server
mysqld program has to write its
.pid files to
/var/run/mysqld/ directory. But we know from FHS (Filesystem Hierarchy Standard) that:
Files under this directory must be cleared (removed or truncated as appropriate) at the beginning of the boot process.
mysqld has to create
/mysqld directory under
/var/run/ every time MySQL server is started.
The owner and group of
drwxr-xr-x 13 root root 4096 may 20 23:41 var.
And we also know from FHS (Filesystem Hierarchy Standard) that:
/var/run should be unwritable for unprivileged users (root or users running daemons); it is a major security problem if any user can write in this directory.
mysqld cannot write to the directory. Indeed when I run
mysqld to start MySQL server I always get an error:
user@user-desktop:~$ sudo mysqld --console 130720 23:43:02 [ERROR] Can't start server : Bind on unix socket: Permission denied 130720 23:43:02 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ? 130720 23:43:02 [ERROR] Aborting
The question is: how
mysqld can write
.pid files to
/var/run/mysqld/ if standard forbids to open this directory for writing? This is a clear contradiction, isn't it?
My question is: how to let
mysqld to create and write its files to
/var/run/mysqld/ without changing permissions of the
/var/run directory? For now I see the only way:
user@user-desktop:$ sudo chmod a+w /var
But it is forbidden by the Standard.