From owner-freebsd-questions@FreeBSD.ORG Fri Sep 3 14:46:52 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7CCFB16A4CE for ; Fri, 3 Sep 2004 14:46:52 +0000 (GMT) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0F7A643D31 for ; Fri, 3 Sep 2004 14:46:52 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.11.7p1+Sun/8.11.7) id i83EkAi02437; Fri, 3 Sep 2004 10:46:10 -0400 (EDT) From: Jerry McAllister Message-Id: <200409031446.i83EkAi02437@clunix.cl.msu.edu> To: bsilver@chrononomicon.com (Bart Silverstrim) Date: Fri, 3 Sep 2004 10:46:09 -0400 (EDT) In-Reply-To: <1D64B3BF-FDAF-11D8-ABDA-000D9338770A@chrononomicon.com> from "Bart Silverstrim" at Sep 03, 2004 09:42:36 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: Moving MySQL database X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Sep 2004 14:46:52 -0000 > > I have a server that is rapidly filling the var partition with a MySQL > database. I'd like to move it to a subdirectory somewhere under /usr. > > Is there a document that would outline a "best practices" approach to > doing this? My first instinct was to stop the mysqld, do a mv on > /var/db to /var/db2 to rename it, copy the data to a /usr/local/db > folder and alter permissions on it to match /var/db, then make a > softlink between /usr/local/db and /var/db and restart mysqld so mysqld > wouldn't need any reconfiguring and everything, I would *think*, should > keep working...only now it will be working off a far more spacious > partition. presuming /usr is actually a good place for it (may really want to add a disk and make a really different partition) First stop MySQL or reboot to single user. Then cd /var/db tar cf /usr/db.tar * cd /usr mkdir var.db cd var.db tar xf ../db.tar cd /var mv db db.old ln -s /usr/var.db db Now, reboot and let MySQL start and make sure it all is happy and works just fine. Then clean up. cd /usr rm db.tar cd /var rm -rf db.old It should now work using the space in /usr You can use any names you like for db.tar, var.db, db.old. Those just make sense to me and are the style I use. If you don't want to move all the stuff in /var/db, then you will have to be more selective and make the link from within /var/db rather than just the whole db directory from within /var. For example, the MySQL stuff is likely to all be in a directory called /var/db/mysql. So: Stop MySQL or reboot to single user. Then cd /var/db/mysql tar cf /usr/mysql.tar * cd /usr mkdir var.db.mysql cd var.db.mysql tar xf ../../mysql.tar cd /var/db mv mysql mysql.old ln -s /usr/var.db.mysql mysql Now, reboot and let MySQL start and make sure it all is happy and works just fine. Then clean up. cd /usr rm mysql.tar cd /var/db rm -rf mysql.old ////jerry > > Thanks, > -Bart >