LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem changing mysql uid,gid: mysql start fails (https://www.linuxquestions.org/questions/linux-newbie-8/problem-changing-mysql-uid-gid-mysql-start-fails-791027/)

gjatute 02-23-2010 10:45 AM

Problem changing mysql uid,gid: mysql start fails
 
Dear all,

first of all I'm not sure whether this is the right section where to post this question. I'm not exactly a newbie in terms of linux, but I really have no clue, so I feel like being a newbie.

I need to move /var/lib/mysql directory because of space problems: the original location is a virtual machine and the new location is a directory nfs-mounted on the virtual machine (this just to explain why I want to change mysql uid/gid). Since this way the destination is a directory shared by two hosts I need first of all to make mysql uid and gid uniform in the two (the uniform uid/gid is a problem that I faced already in this kind of sharing, this is why I assume it's the firts thing to do).

I did the following
Code:

/etc/init.d/mysql stop
usermod -u xxx mysql
groupmod -g yyy mysql

The problem is that when I try to restart mysql it fails. Restoring the original uid/gid mysql starts without any problem.

If there's somebody that can give me a hint... I really have no idea!

Thank you in advance

Tinkster 02-23-2010 11:51 AM

I'll start with a question:

Why the usermod/groupmod commands? What are you trying to
achieve?

gjatute 02-23-2010 03:43 PM

Quote:

Originally Posted by Tinkster (Post 3874020)
I'll start with a question:

Why the usermod/groupmod commands? What are you trying to
achieve?

I want to move /var/lib/mysql in /some/directory/mysql

The first is in a virtual machine (running in a certain other machine), the second is a directory in the host of the VM and mounted in the virtual machine.

When I first mounted let's say /some/directory in the VM, I started to have huge problems with permissions (when reading/writing files in the mounted dir) and this was due to the fact that the users were not well mapped between guest and host. I solved the problem making uniform uid and gid in the VM (guest) and in the host (since in the beginning they were different).

I assume mysql would have the same problems, this is why I imagine this is the first thing to take care of (before even try to move /var/lib/mysql).

Tinkster 02-23-2010 06:18 PM

So ... what's the host OS, how is the drive shared,
and what is the current UID & GID on it? Realistically
you should just have to make sure all relevant files &
dirs (this includes config, logging, run etc) have the
corret (identical) owner.

gjatute 02-24-2010 08:25 AM

Well,
* the host OS is a RedHat (the guest is debian)
* the 'shared' directory is actually an nfs mount on the virtual-debian (I don't know if this is a satisfactory reply)
* on the RedHat host "id mysql" gives uid=505 and gid=505 [..] (in the debian guest uid=104 and gid=107 [..])

Quote:

Realistically
you should just have to make sure all relevant files &
dirs (this includes config, logging, run etc) have the
corret (identical) owner.
I don't understand exactly this part: in principle doing groupmod and usermod in the debian guest I am just "changing the numbers". So why do I already have problems in starting mysql without moving anything? What am I missing?

BTW: thank you very much for the attention and the help!

zhjim 02-24-2010 08:39 AM

I'd say that after you changed the gid and uid they don't match whats on the filesystem itself.
An Example to explain what I mean

Before change of id's

mysql gid: 100
mysql uid: 100
files owned by mysql: uid:100 gid:100

After change of id's
mysql gid: 200
mysql uid: 200
files owned by mysql: uid:100 gid:100

So when you start mysql it comes along with 200/200 but the files are only allowed to be used by 100/100. Just because ls shows ownage by mysql before does not mean they are owned by mysql after change. (specialy because ls just converts gid/uid into names. Internaly it just goes with numbers)

But before chowning the files on the new space. Make sure that the new mysql owner is allowed to write on the new space.

gjatute 02-24-2010 09:04 AM

Quote:

Originally Posted by zhjim (Post 3875071)
Just because ls shows ownage by mysql before does not mean they are owned by mysql after change. (specialy because ls just converts gid/uid into names. Internaly it just goes with numbers)

But before chowning the files on the new space. Make sure that the new mysql owner is allowed to write on the new space.

Ok, thanks. This is probably exactly what I'm missing: using "ls -ln" instead of "ll" appears evident that while the owner of the files is automatically changed after usermod the group keeps being the old one also after the groupmod (I'm not too expert, this is a little bit funny, no?).

So the idea is that now I have to fish all the files of the group mysql and chsomething them?

zhjim 02-25-2010 01:38 AM

Quote:

Originally Posted by gjatute (Post 3875097)
Ok, thanks. This is probably exactly what I'm missing: using "ls -ln" instead of "ll" appears evident that while the owner of the files is automatically changed after usermod the group keeps being the old one also after the groupmod (I'm not too expert, this is a little bit funny, no?).

I doubt that the owner changes automatically. I'd say that it just happens to be the same uid on both servers... But then there would be no need to usermod and change the uid.

Quote:

Originally Posted by gjatute (Post 3875097)
So the idea is that now I have to fish all the files of the group mysql and chsomething them?

The command your looking for is chown
But like I sad first make sure that the new mysql user can write on the NFS share. After that you can chown the directory and all the files inside the new mysql_data_dir.


All times are GMT -5. The time now is 06:51 AM.