[nzlug] Copying mysql database - without running binary, DB files only

Michal Ludvig michal at logix.cz
Sat Sep 16 23:57:46 NZST 2006


Howard wrote:
> Is is possible to rebuild a mysql database file without the running
> binaries on the system - just db files? i.e. I can't do a mysqldump or
> similar.

> I am assuming the required database files are in /var ?

Depends on system - could be in /var/lib/mysql but see below.

> Anything else I would need to copy across e.g. config files? I assume
> user info is stored in the DBs?

my.cnf will definitely help - it's usually in /etc/my.cnf or
/etc/mysql/my.cnf. Look for "datadir" directive in there to see where
the data files are. Then tar up the data dir, add my.cnf to it and
transfer to the other machine. Over there stop mysql server, move its
original datadir somewhere, untar the archive, replace the config file
and start mysql server.

If the old server has crashed you may need to myisamchk all tables.
InnoDB tables should be repaired automatically on start. There is as
well an option for autorepair if myisam tables - check the manual for
the option name.

> How sensitive would the version of mysql be - would I likely need the
> exact mysql build on the new system?

It should be the same or higher version. Quite likely roughly the same
versions will do (e.g. if the crashed machine is 5.0.24 and you unpack
it to 5.0.22 it will probably work just fine). Just make sure that the
new server has all the features of the old one - e.g. all the same
engines and character sets compiled in.


Michal






More information about the NZLUG mailing list