Can I tell MySQL to store specific databases in specific folders?

Lets say I have 2 databases, "foo" and "bar", and I want MySQL to store "foo" in "/media/foo", and "bar" in "/media/bar", can this be done in MySQL 5.5 or later?


Normally each database is already in a subdirectory of its own. From the manual :

A database in MySQL is implemented as a directory containing files that correspond to tables in the database. Because there are no tables in a database when it is initially created, the CREATE DATABASE statement creates only a directory under the MySQL data directory and the db.opt file.
...
If you manually create a directory under the data directory (for example, with mkdir), the server considers it a database directory and it shows up in the output of SHOW DATABASES.

With InnoDB with the DATA DIRECTORY = absolute_path_to_directory clause of the CREATE TABLE statement you can even create tables outside of the normal MySQL (sub-) directory structures