MySQL tables on external hard drive

Michael picture Michael · May 27, 2011 · Viewed 9.2k times · Source

I have a large amount of text data I need to import into MySQL. I'm doing this on a MacBook and don't have enough space for it so I want to store it in an external hard drive (I'm not really concerned about speed at this point - this is just for testing).

What's the best way to do it?

  • Install MySQL on the external hard drive (is this possible on a Mac?)
  • Install MySQL on the laptop's hard drive and have the tables on the external (how?)

Answer

user658991 picture user658991 · May 27, 2011

One simple hack is to create an symbolic link replacing your current mysql database file location pointing to the external disk. Google symbolic link.

sample usage would be after you shutdown mysql, change the old mysql db folder name to something else, and create the symbolic link using the ln command like below

ln -s [EXTERNAL DRIVE PATH] [MYSQL DB FOLDER PATH]

Then move all the previous content of the mysql db folder to the new location.