2

Is it possible to set each database in MySQL to use a separate datadir?

I'm running a userdir development (sandbox) server and would like to put the MySQL data files for the database(s) for that user in their /home/<user>/mysql directory. How would you do this?

  • Linux Ubuntu Server 10.4
  • MySQL Server version: 5.1.41
  • Storage Engine type: InnoDB
Highway of Life
  • 496
  • 1
  • 7
  • 14

1 Answers1

2

If you are not using INNODB or the innodb_file_per_table, then just stop the database server, move the database folder to whatever location you like, then create a symbolic link to the new location from the mysql folder. Mysql will still need access to the files, so you can't simply change the permissions so that particular user owns the directory/files though. Please do test first with test data.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • Same process for myisam files - but you move the directory containing the database. Or use the DATA / INDEX DIRECTORY options on CREATE TABLE – symcbean Mar 13 '12 at 10:36