# How to save a MySQL database on another drive?

In my app, I use MySQL for the database backend (the app uses multiple MySQL databases, all use MyISAM tables). For performance reasons, I want to move one of the databases to a solid state drive (DRAM based), but only that database, the other databases should stay on the SATA drive I use. As you know, in MySQL you can only specify the data directory in MySQL settings and you don't have control over where every database is saved. Is there any workaround for this? I'm hoping that there might some trick I'm not aware of that can get the job done.

Any suggestions would be really appreciated, thanks

-

Assuming your SSD has the drive letter G:\ you move your specific database subdirectory to the new drive and create a symlink in the 'datadir' directory.

mklink /D database_subdir G:\path\to\database


Best wishes, Fabian

-
Any performance hit with a symlink? –  gap Oct 19 '11 at 18:36

Assuming you are running on a Linux server and are set up for seperate files for each database, you could try moving the database subdirectory and symlinking the database file subdirectory.

-
Thanks for you answer. Actually I have MySQL running on a Windows machine (so far at least). I see MySQL create a separate directory for each database but all under the data directory of MySQL. Are things different on Linux? –  Mee Dec 2 '09 at 15:17
We have 'innodb_file_per_table' set in the MySQL configuration which saves the data in seperate files under the data directory in a subdirectory with the database name. With Linux (or Unix) you can create a symbolic link to a file or directory that acts like an alias to the actual directory or file. –  Craig Dec 2 '09 at 15:34
you can create symlinks in windows server 2008 and vista. Use the mklink command. –  Jure1873 Dec 2 '09 at 15:53
symlinking with innodb_file_per_table is fraught with gotchas, particularly any alter-table statement will break it. –  cagenut Dec 2 '09 at 18:47