location of mysql database files?

Rick Stevens rstevens at vitalstream.com
Thu Aug 11 20:18:04 UTC 2005


Harold Hallikainen wrote:
> 
>>The only _reliable_ method for moving mysql data from machine to machine
>>is via mysqldump/mysqlrestore or by using the replication tools in the
>>later versions of mysql.  Moving the data files around is not
>>recommended--especially with a live database.  If you can stop it while
>>you move the binary files, then you're OK, but don't do it while mysql
>>is running.
>>
>>BTW, the default location for the data files is
>>
>>	/var/lib/mysql/name-of-database
>>
>>Inside each directory, the files are named *.frm, *.MYD, and *.MYI,
>>where the asterisks are replaced by the table names.  10 tables yields
>>30 files (a .frm, a .MYD and a .MYI for each)
>>
> 
> 
> 
> I tried copying the mysql files over from the RH8 machine to the FC4, and
> it LOOKS like it worked, but the owners have changed from harold to root
> (I have to use -uroot in mysql to see the databases). Is user info and
> database ownership info in the same location as the databases? I may still
> go the export/import route, but I'm trying to use rsync to keep a backup
> server in sync with another.

If you don't specify "-p" on the cp command, _new_ files will be created
with the UID/GID of the process doing the cp command.  Since these
files didn't exist on the FC4 machine and you did the "cp" as root,
the files got "root:root" ownership.

As root, you can "chown -R harold:haroldsgroup /var/lib/mysql/dbname/*"
to set the ownerships back to harold (assuming the user harold is set up
on the machine).  The permissions regarding who's allowed to do what to
each database is stored in the "mysql" database:

	# mysql
	> connect mysql
	> show tables\g

I'd recommend getting the O'Reilly book, "MySQL & mSQL" by Yarger, Reese
and King (a.k.a. the "woodpecker" book).  It's pretty good.
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-        Brain:  The organ with which we think that we think.        -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list