"chown mysql:mysql /data/tmp" command
The Command
- That
chown
command does exactly what you expect it does. - In most systems I'm familiar with, the default directory tree is part of /var/lib/mysql/
- For the
chown
command to make sense, somebody must have amy.cnf
that refers to /data/tmp, associated system variable, or command line flag.- http://dev.mysql.com/doc/refman/5.0/en/temporary-files.html (descriptive doc)
- http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_tmpdir (places server variable can be set)
The User Account
On Ubuntu (which you tagged this), MySQL is usually installed by apt-get
. The MySQL APT package includes script that automatically create the MySQL user when the software is installed.
Related videos on Youtube
Comments
-
Mellon over 1 year
I am on a Linux ubuntu machine with MySQL installed.
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 (my questions):
1. Why would one run the above command? If I create a table in
my_db
database, by default, there will be.frm
,.MYD
, and.MYI
files (data files) be created automatically by MySQL under/var/lib/mysql/my_db/
. So, does the above command changes the default MySQL data directory to/data/tmp/
instead of/var/lib/mysql/my_db/
?Basically, I would like to know the purpose and effect of the above command. (better with examples)
2. Where does the 'mysql' owner and group come from? Does the installation of MySQL on a Linux machine automatically create the 'mysql' user and group? or People need to manually create a
mysql
account for the linux machine? -
Mellon over 12 yearsWhat is the full path to /data/tmp ?? I just do not know where can I find it... and where is my.cnf??
-
Mellon over 12 yearsYou talked about two ways to change, are they both need to be done or either one is ok?
-
loislo over 12 years@Mellon the path literally is
/data/tmp
. At least on my Ubuntu configuration, that's not a default path (nor does /data exist as a directory). The default Ubuntu location for my.cnf is/etc/mysql/my.cnf
-
Mellon over 12 yearsAlso, if I change the passwd file, and change the mysql dir to /data/tmp , does it means in future all the database related files .frm, .MYD and .MYI will be created under /data/tmp/ ?
-
Mellon over 12 years@ Jeff, so you mean I have to manually first create /data/tmp, and it can be an arbitrary path right?? Besides, in the my.cnf file, if I change the mysql directory to /data/tmp , does it means in future all the database related files .frm, .MYD and .MYI will be created under /data/tmp/ ?
-
loislo over 12 yearsWhy are you focusing on /data/tmp? If you don't know why you're doing that, stop. Unless you have a specific need you can explain for changing the default directories, don't do it. You're asking a question that is above your understanding -- you don't yet know why /data/tmp might matter to you (and I'm guessing it won't), so take a step back from trying to do the work to move there.
-
Mellon over 12 years@ Jeff, the reason why I am focusing on /data/tmp is because my teacher gave out an assignment which mentioned "copy cars.dat to /data/tmp on the database server" without any explanations, I do not know what is the "/data/tmp on database server" means? Appreicate if you can explain.
-
loislo over 12 years@Mellon Without any other context, it means
mkdir -p /data/tmp && cp cars.dat /data/tmp
-
Mellon over 12 yearsBut it mentioned "/data/tmp on database server", it must be something more than just create the directory, because it said "on database server"
-
loislo over 12 years@Mellon You don't understand the bounds of the problem you're given, and I don't have the context to help you out. I would assume that you would have shell access to the db server, but that may not be the case. You need to ask your prof or a classmate.
-
Flash over 12 yearsthe home folder change (in /etc/passwd) will make files like ibdata1, ib_logfile0 and mysql.sock go into the dir specified. the change to the datadir in my.cnf will make the databases go there, Every database will have its own subdir like before with the files that belong to that database in that folder.