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.

Afaque H
  • 41
  • 6

1 Answers1

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 :).

Afaque H
  • 41
  • 6
  • check for a hidden lock file in /etc. That sometime break useradd/usermod etc commands without error emssage. – mveroone Mar 21 '14 at 12:46