1

My question would be, is there any way to read the mysql data folder from different drives in the same time (Windows) ?

For example: I have 1TB database from the drive C:, and another 1TB from the drive D:. So when I start mysql it will simply see both databases from both drives.

1 Answer 1

2

A given instance of MySQL can only use one datadir. Under the datadir, each MySQL schema lives in a subdirectory.

For example, the default datadir is C:\Program Files\MySQL\MySQL Server 8.0\data.

Schema1 would be under C:\Program Files\MySQL\MySQL Server 8.0\data\Schema1

Schema2 would be under C:\Program Files\MySQL\MySQL Server 8.0\data\Schema2

But if you could trick Windows into thinking that Schema2 subfolder actually uses storage from your physical drive D:, then you could achieve what you want.

One method is to use mklink as shown here: https://dev.mysql.com/doc/refman/8.0/en/windows-symbolic-links.html I would prefer this solution because it allows you to target a specific path on your D: drive.

A second option is to use virtual drives. Windows allows you to map drives to specific paths of another drive. Not many Windows users employ this option, they prefer to use drives as drive letters instead.

https://winaero.com/create-virtual-drive-from-a-folder-in-windows-10/

So you would use

SUBST D: C:\Program Files\MySQL\MySQL Server 8.0\data\Schema2

Read the article I linked to for more details.

Whichever solution you use, now files under Schema2 are automatically stored on your physical drive D:, and do not take up space on the physical drive C:.

What if you have already created the Schema2? So there is already a subdirectory for that schema's tables on C:. Well, you'll have to do some file juggling to make that work. I don't have a Windows machine so I can't test it or give advice on what the steps are.

Remember not to do any manual moving of MySQL tables around while the MySQL Server service is running. Stop the service first, or you will corrupt your data. Practice this sort of configuration on another server, not your important production data, and also make a backup of the whole database instance before you try anything.

3
  • Thank you for the detailed answer. I'll try to use your solution. :) Commented May 3, 2021 at 14:19
  • works!!! really thank you for the help!!! :) Commented May 5, 2021 at 11:24
  • @carouselcarousel - I don't think SUBST is what you want. MKLINK sounds right.
    – Rick James
    Commented May 16, 2021 at 1:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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