外部硬盘上的MySQL表

时间:2022-09-24 11:08:59

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).

我需要导入MySQL的大量文本数据。我在MacBook上做这个并且没有足够的空间,所以我想将它存储在外部硬盘中(我现在并不关心速度 - 这只是用于测试)。

What's the best way to do it?

最好的方法是什么?

  • Install MySQL on the external hard drive (is this possible on a Mac?)
  • 在外置硬盘上安装MySQL(在Mac上可以吗?)

  • Install MySQL on the laptop's hard drive and have the tables on the external (how?)
  • 在笔记本电脑的硬盘上安装MySQL并在外部安装表(如何?)

3 个解决方案

#1


3  

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

一个简单的方法就是创建一个符号链接来替换当前指向外部磁盘的mysql数据库文件位置。谷歌的象征性链接。

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

关闭mysql之后的示例用法,将旧的mysql db文件夹名称更改为其他名称,并使用ln命令创建符号链接,如下所示

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

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

然后将mysql db文件夹的所有先前内容移动到新位置。

#2


0  

For the second option, a tablespace might do the trick:

对于第二个选项,表空间可能会起作用:

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

#3


0  

User user658991 answer is halfway there.

用户user658991答案就在那里。

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

添加软链接后,您需要将以下行添加到2行下面的/etc/apparmor.d/usr.sbin.mysqld到旧的mysql文件夹。

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

Without these 2 lines, MySQL fails to start complaining of:

如果没有这两行,MySQL就无法开始抱怨:

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 changes to take effect.

重新启动apparmor以使更改生效。

sudo invoke-rc.d apparmor restart

With this, MySQL starts normally.

有了这个,MySQL正常启动。

#1


3  

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

一个简单的方法就是创建一个符号链接来替换当前指向外部磁盘的mysql数据库文件位置。谷歌的象征性链接。

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

关闭mysql之后的示例用法,将旧的mysql db文件夹名称更改为其他名称,并使用ln命令创建符号链接,如下所示

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

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

然后将mysql db文件夹的所有先前内容移动到新位置。

#2


0  

For the second option, a tablespace might do the trick:

对于第二个选项,表空间可能会起作用:

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

#3


0  

User user658991 answer is halfway there.

用户user658991答案就在那里。

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

添加软链接后,您需要将以下行添加到2行下面的/etc/apparmor.d/usr.sbin.mysqld到旧的mysql文件夹。

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

Without these 2 lines, MySQL fails to start complaining of:

如果没有这两行,MySQL就无法开始抱怨:

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 changes to take effect.

重新启动apparmor以使更改生效。

sudo invoke-rc.d apparmor restart

With this, MySQL starts normally.

有了这个,MySQL正常启动。