Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know what the linux command chown does, I used it to change the ownership or group of a file.

If there is a MySQL installation on a Ubuntu machine, I saw some people doing the following thing:

sudo chown mysql:mysql /data/tmp

I get confused, I know the meaning of the above command, which is to change the owner of /data/tmp to user 'mysql' and change the group of it to 'mysql' group.

But:

1. Why would one run the above command?
2. Where do the 'mysql' owner and group come from? Does the installation of MySQL on a Linux machine automatically create the 'mysql' user and group?

share|improve this question
2  
2. Yes, many daemons are run with a dedicated user/group which is usually created when the package is installed. –  Stéphane Gimenez Nov 30 '11 at 10:45
    
...and 1.) because otherwise the DBMS won't be able to read/write the data –  symcbean Nov 30 '11 at 11:39
    
Symcbean, do you mean those .frm .MYD .MYI files can be created by MySQL to the directory /data/tmp/ when a table created? –  Mellon Nov 30 '11 at 11:46
    
@symcbean why the mysql installtion itself does'nt change the ownerships automaticly at the installation stage? –  Hanan N. Nov 30 '11 at 13:14
    
@Hanan N.: typically most installers will do this at the same time as creating the users (i.e. when they're running as root). But /data/tmp is NOT a default path for any mysql data files - if you change the paths after installation, then you need to make suer that the new locations are accessible. –  symcbean Nov 30 '11 at 13:27
show 2 more comments

2 Answers

There are some reasons to do it like this way.

  1. When you are installing mysql on your Linux machine. mysql user and groups installed automatically.

  2. Why user/group is required for this action ? It s required for security reasons. You want to give a permission to user which one will use the mysql. And also you give the permission on /data/tmp . Because your database files stored in there by default.

share|improve this answer
add comment

The installation of the MySQL package in Ubuntu creates a mysql user and a group of the same name. This is the user that the MySQL daemon process runs under, and many MySQL-related files belong to that user. If you install MySQL manually, you may need to create the user yourself.

chown mysql:mysql /data/tmp (executed as root) makes the user mysql and the group mysql the owning user and owning group of the file or directory /data/tmp. I don't know why these people did it, you'd have to ask them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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