When installing mysql-server on Debian Wheezy, the user "mysql" is created without a home directory. In my setup, directly after MySQL was installed, a new task is performed which relies on the mysql user having /var/lib/mysql as home directory.

At the moment, this task fails. I have to adjust the mysql user and re-run my task again. So what I am looking for is a builtin method in Debian which allows me to either "preseed" the home dir of the mysql user (which is created by one of the mysql packages) or creating a trigger which reacts on the event of the mysql-server package being installed (or the mysql user being created, I don't care).

I know that I could modify the mysql package or wrap mysql installation in some sort of script or puppet manifest; however, things like this are not suitable for my setup. I need a clean Debian method to do it.

Is there something existing which could be triggered on package installation or user creation? I thought about watching mysql files via inotify as a workaround; however, I think that inotify would be too much for my little problem here.

I am currently looking at dpkg-triggers, but I am not sure if this is the right solution..

  • Sounds like you just need to amend your post-install process to not require mysql to have a proper home dir. You've essentially ruled out any other reasonable way to resolve this. – EEAA Apr 3 '14 at 21:21

You can create the user mysql just before installation of the package. If you look at the preinst script of the package, this won't break anything:

# creating mysql user if he isn't already there
if ! getent passwd mysql >/dev/null; then
    # Adding system user: mysql.
    adduser \
        --system \
        --disabled-login \
        --ingroup mysql \
        --no-create-home \
        --home /nonexistent \
        --gecos "MySQL Server" \
        --shell /bin/false \
        mysql  >/dev/null


| improve this answer | |
  • That was exactly what I was looking for, ty! However, I just found out that the MySQL package on Debian "unsets" the home of the mysql user afterwards, so I still have to find another way. – Valentin Apr 5 '14 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.