如何为mysql添加额外的配置文件(my.cnf) [英] How can I add an extra configuration file for mysql (my.cnf)

查看:663
本文介绍了如何为mysql添加额外的配置文件(my.cnf)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为UNIX上的MySQL添加和额外的配置文件,我们将其称为my2.cnf.因此,当MySQL启动时,它也会读取该文件的选项.

I want to add and extra configuration file for MySQL on UNIX, let's call it my2.cnf. So when MySQL starts, it would read the options of that file too.

在这里,它说我可以放一个文件放在以下位置:

Here it says that I can put a file on the following places:

  • /etc/my.cnf
  • SYSCONFDIR/my.cnf
  • $ MYSQL_HOME/my.cnf
  • defaults-extra-file用--defaults-extra-file = path指定的文件(如果有的话)
  • 〜/.my.cnf用户特定的选项

我想要这样的"default-extra-file",但避免在mysql提示符下输入此命令.

I would like something like this "default-extra-file", but avoiding to enter this command on the mysql prompt.

cnf文件中是否有一个选项,如:

Is there an option in the cnf file like:

 extra-conf-file=/path/to/my/file/my2.cnf

(不幸的是,这不起作用)

(Unfortunately that does not work)

那有可能吗?我可以使用默认的my.cnf文件添加另一个配置文件,该文件将在启动mysql服务时读取吗?

Is that even possible? Can I use the default my.cnf file to add another configuration file that will be read when I start themysql service?

(使用$ MYSQL_HOME/my.cnf对我来说已经足够好了,但是我想知道是否可以明确地告诉我,以便可以根据主要my.cnf全局文件读取或忽略它).

(Using $MYSQL_HOME/my.cnf is good enough for me, but I would like to know if I can explicetely tell so it can be read or ignored according to the main my.cnf global file).

推荐答案

我想这就是您想要的吗?

I guess this is what you want right ?

!include /path/to/my/file/my2.cnf

您还可以使用以下方法从目录中包含完整的文件集:

You can also include a complete set of files from a directory using:

!includedir /path/to/my.cnf.d

这篇关于如何为mysql添加额外的配置文件(my.cnf)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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