1

So I've been trying to find a way to locate 2 databases within different directories.

The reason I want to do this, is because I have a relatively small database that hardly changes, that I want to locate on the local drive of the server. The other database is ever changing, and so I want to locate it on my SAN. But, I want to control both from the same MySQL server.

I know how to change the default data directory, by doing something along the lines of this

And, after searching through google, it seems that it can only be done by setting up multiple instances, each with their own default data directory.

Have I missed something?

Community
  • 1
  • 1
Just Lucky Really
  • 1,341
  • 1
  • 15
  • 38

1 Answers1

0

You're thinking about this too much. Change the datadir to the one you want to use the most. Then, mount the other folders in the datadir. Symlinks will work but you will have to change AppArmor, etc.

Each database has a folder in the datadir. So, just link to or mount this folder. Make sure it's mounted before starting MySQL.

Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77
exussum
  • 18,275
  • 8
  • 32
  • 65
  • Yeah this is the line I was thinking of going down ... Just wasn't 100% sure if this was an 'invalid' config ... Thanks :D – Just Lucky Really Dec 14 '14 at 02:20
  • With database directories as mounts or symlinks, it's valid. Symlinking individual tablespace files (.ibd, .MYD, etc.) is not a supported configuration. – Michael - sqlbot Dec 14 '14 at 22:08
  • Note that if you use InnoDB tablespaces, you might need to set `innodb-file-per-table=On`, otherwise your InnoDB data might end up in one enormous file in the `datadir` instead of your separately-mounted/symlinked directories. – Christopher Schultz Dec 06 '18 at 17:44