Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Dec 2001 12:06:34 -0600 (CST)
From:      Ryan Thompson <ryan@sasknow.com>
To:        Jason Halbert <jason@jason-n3xt.org>
Cc:        <questions@FreeBSD.ORG>
Subject:   Re: Moving MySQL Databases
Message-ID:  <20011227115010.M21746-100000@catalyst.sasknow.net>
In-Reply-To: <20011227174410.D399637B41C@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Jason Halbert wrote to questions@FreeBSD.ORG:

> Does anyone know how to move MySQL databases from one box to another?
>  I am upgrading my server and I would like to move my Qmail and
> Apache databases over.  It would be a nightmare to have to recreate
> them from scratch.

If the MySQL versions are the same (or compatible), you can just
directly copy the contents of /var/db/mysql to the new server.  I've
successfully done this more than once, using something like the
following approach:

	oldserver# /usr/local/etc/rc.d/mysql-server.sh stop
	oldserver# cd /var/db && tar -cvzf mysql.tar.gz mysql
	oldserver# /usr/local/etc/rc.d/mysql-server.sh start

	(send file to newserver with ftp, [sr]cp, NFS, tape, etc)

	newserver# /usr/local/etc/rc.d/mysql-server.sh stop
	newserver# mv /var/db/mysql /var/db/mysql.`date +%Y%m%d`
	newserver# cd /var/db && tar -xvzf /path/to/mysql.tar.gz
	newserver# /usr/local/etc/rc.d/mysql-server.sh start

Note that this completely replaces the mySQL databases (including the
MySQL access priv database, and anything else you might have created
for the new server). If you actually need to merge individual
databases, you can follow a similar scenario, but just copy the
subdirectory under MySQL that contains the database you want. (For
example /var/db/mysql/apache for a database called "apache").

Also note that I stopped and started the server before working
directly with the raw database files files. This is an extremely good
idea... otherwise, if there are ANY open database connections on
newserver, I would expect this to fail.


> Thanks for any help.
>
> Jason
> jason@jason-n3xt.org
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
>

-- 
  Ryan Thompson <ryan@sasknow.com>
  Network Administrator, Accounts

  SaskNow Technologies - http://www.sasknow.com
  #106-380 3120 8th St E - Saskatoon, SK - S7H 0W2

        Tel: 306-664-3600   Fax: 306-664-1161   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011227115010.M21746-100000>