MySQL tables on an external hard drive

I have a lot of text data that I need to import into MySQL. I do this on a MacBook and donโ€™t have enough space for this, so I want to save it to an external hard drive (at the moment Iโ€™m not really worried about speed - it's just for testing).

What is the best way to do this?

  • Install MySQL on an external hard drive (is this possible on a Mac?)
  • Install MySQL on the laptop hard drive and have tables on the external (how?)
+4
source share
3 answers

One simple hack is to create a symlink replacing the current location of the mysql database file pointing to an external drive. Google symbolic link.

Using the example will be after mysql is completed, changing the old mysql db database name to something else and creating a symbolic link using the ln command, as shown below

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

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

+3
source

For the second option, the tablespace can do the trick:

http://dev.mysql.com/doc/refman/5.1/en/create-tablespace.html

0
source

User user658991 is responding halfway.

After adding the soft link, you will need to add the following line to /etc/apparmor.d/usr.sbin.mysqld under two lines in the old mysql folder.

 /path/to/mysql/folder/on/the/external/ r /path/to/mysql/folder/on/the/external/ ** rwk 

Without these two lines, MySQL cannot start complaining:

 Can't create test file /path/to/mysql/folder/on/the/external/hostname.lower-test Can't create test file /path/to/mysql/folder/on/the/external/hostname.lower-test mysqld: Can't change dir to '/path/to/mysql/folder/on/the/external/' (Errcode: 13) 

Restart apparmor for the change to take effect.

 sudo invoke-rc.d apparmor restart 

In this case, MySQL starts normally.

0
source

All Articles