Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
I'm not entirely sure you can. Not without running each one inside it's own chroot inside ~username. – Tom O'Connor Mar 12 '12 at 21:39
up vote 2 down vote accepted

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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.