使用不同的数据目录设置多个 MySQL 数据库 [英] Setting up multiple MySQL databases with different data directories

查看:100
本文介绍了使用不同的数据目录设置多个 MySQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直试图找到一种方法来在不同的目录中定位 2 个数据库.

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

我之所以要这样做,是因为我有一个相对较小的数据库,几乎不会更改,我想将其定位在服务器的本地驱动器上.另一个数据库一直在变化,所以我想在我的 SAN 上找到它.但是,我想从同一个 MySQL 服务器控制两者.

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

而且,通过google搜索后,似乎只能通过设置多个实例来完成,每个实例都有自己的默认数据目录.

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.

我错过了什么吗?

推荐答案

你想太多了.将 datadir 更改为您最想使用的那个.然后,挂载datadir 中的其他文件夹.符号链接可以使用,但您必须更改 AppArmor 等.

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.

每个数据库在 datadir 中都有一个文件夹.因此,只需链接或挂载此文件夹即可.在启动 MySQL 之前确保它已安装.

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

这篇关于使用不同的数据目录设置多个 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆