Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 12-25-2012, 12:33 AM   #1
Registered: Nov 2008
Posts: 985

Rep: Reputation: Disabled
Post Moving only ONE MySQL database to a different folder, is it possible?

Hi all!

So my Mysql databases are all located in /var/lib/mysql which is located on /var (small partition of 11GB). Unfortunately one of the databases is getting wayyy bigger than I initially hoped for (8.5GB and growing) and as a result, /var is getting full and I am experiencing all kind of strange issues with my server (apache crashes, pages dont load, etc...).

I cleaned up /var a bit and freed about 200MB (deleted tons of logs) but this will buy me maybe a few weeks before the database grows even more and fill /var once again.

So my question: Can I safely move this huge database to a different location (drive or partition) of bigger capacity while keeping all other DB's where they are currently located? The reason being, the current location of /var is located on reliable hard drives mounted in a RAID1 array and automatically backed up to a third HDD. The other drive I would use to relocate the big DB would be a single drive not so reliable (for financial reasons, and eventually will get replaced or RAID'ed)..

I have found websites describing how to move the whole mysql DB repository (in my case /var/lib/mysql) but not how to move a single DB...

Anybody knows?

many thanks to all!!!
Old 12-25-2012, 08:45 PM   #2
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 867

Rep: Reputation: 264Reputation: 264Reputation: 264
Old 12-30-2012, 12:01 PM   #3
Registered: Nov 2008
Posts: 985

Original Poster
Rep: Reputation: Disabled
wildwizard, this is what I ended up doing... I am not a huge mysql user but I believe the future versions of MySQL should be able to work with databases located in different folders/drives etc... Would be a lot more flexible and dependable..

Anyways, I have created a symlink pointing to a huge drive where I have moved the databases. Works well so far...

At first I had tried this:

1-Stop mysqld
2-change the datadir setting in /etc/my.cnf to point to the new location
3-moved all databases from /var/lib/mysql to the new location
4-restarted mysqld

But it complained files were missing from /var/lib/mysql and ended up... Clearly the datadir setting was not taken into consideration by mysqld.. I wonder why. Reverting the setting in the config file and creating the symlink between /var/lib/mysql to the new location worked immediately...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving 2 months of old files from a folder to another folder. Iyyappan Linux - Server 6 07-13-2012 04:45 AM
Moving a folder, versus moving its contents (within the same partition) the dsc General 7 06-29-2012 04:46 AM
[SOLVED] [APPENDED]Real moving of a folder's content to another folder. MODYSAMA Linux - Newbie 10 02-07-2011 11:30 PM
Moving and replacing entries in a MySQL database kaplan71 Linux - Software 4 04-21-2008 09:06 PM
Moving mySQL database subnet_rx Linux - Software 12 06-30-2004 04:41 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:55 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration