LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 02-23-2010, 11:45 AM   #1
gjatute
LQ Newbie
 
Registered: Jan 2010
Posts: 18

Rep: Reputation: 1
Question 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
 
Old 02-23-2010, 12:51 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
I'll start with a question:

Why the usermod/groupmod commands? What are you trying to
achieve?
 
Old 02-23-2010, 04:43 PM   #3
gjatute
LQ Newbie
 
Registered: Jan 2010
Posts: 18

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by Tinkster View Post
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).
 
Old 02-23-2010, 07:18 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 02-24-2010, 09:25 AM   #5
gjatute
LQ Newbie
 
Registered: Jan 2010
Posts: 18

Original Poster
Rep: Reputation: 1
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!
 
Old 02-24-2010, 09:39 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
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.
 
Old 02-24-2010, 10:04 AM   #7
gjatute
LQ Newbie
 
Registered: Jan 2010
Posts: 18

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by zhjim View Post
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?
 
Old 02-25-2010, 02:38 AM   #8
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
Quote:
Originally Posted by gjatute View Post
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 View Post
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.
 
  


Reply

Tags
gid, mysql, uid


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
yum install php-mysql fails with mysql 5.1 - "Error: mysql conflicts with MySQL" rebelde Linux - Software 2 03-13-2009 11:32 AM
I have RHEL 5.0 and MySQL start problem, my MySQL server doesn't start rsatya Linux - Enterprise 4 02-03-2009 01:04 PM
Mysql problem: after changing root password, cannot start onboot Swakoo Linux - General 3 09-18-2007 05:37 AM
How to start a process with specific uid/gid during bootup? senthilpr_in Linux - Software 5 05-24-2007 12:22 AM
changing uid, gid zeke1955 Linux - General 4 01-10-2004 12:53 AM


All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration