1

I am trying to install MySql on Ubuntu 12.04 but the installation is failing with the error: "Can't change to run as user 'mysql'. Check if the user 'mysql' exits."

So I go ahead type in the command : 'cat /etc/passwd | grep mysql' and result is null.

I try to add a user 'mysql' by issuing the command 'useradd mysql'. But it fails with the message: 'useradd: user 'mysql' already exists'.

When I try to delete the user 'mysql' using the command 'userdel mysql' it also fails with the message "userdel: cannot remove entry 'mysql' from /etc/passwd."

Can anyone explain me what's going on and suggest a solution.

6
  • What does the same grep on /etc/shadow say?
    – Halfgaar
    Oct 23, 2013 at 10:05
  • It is also null.
    – Afaque H
    Oct 23, 2013 at 10:15
  • It may be you've just neglected to paste it in, but shouldn't you be running sudo before all of those commands?
    – NickW
    Oct 23, 2013 at 10:20
  • I do prefix sudo to all commands concerned here.
    – Afaque H
    Oct 23, 2013 at 13:59
  • Thought so :) .. to quote the site "As of Ubuntu 12.04, MySQL 5.5 is installed by default", seems odd you'd have to install it.
    – NickW
    Oct 23, 2013 at 15:01

1 Answer 1

2

Alright, this problem might be because of this bug in Ubuntu, but I am not sure. Anyways, I found a way to solve this problem.

I manually add group mysql by adding the following line to /etc/group:

mysql:x:1024:mysql

Similarly I manually add the user mysql by adding the following line to /etc/passwd:

mysql:x:1024:1024:MySQL Server,,,:/nonexistent:/bin/false

Re-install MySQL:

sudo apt-get remove --purge mysql-*
sudo apt-get install mysql-server

And that was it :).

1
  • check for a hidden lock file in /etc. That sometime break useradd/usermod etc commands without error emssage.
    – mveroone
    Mar 21, 2014 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .