找到你要的答案

Q:read file from inside mysql my.cnf

Q:阅读从MySQL my.cnf文件

I know that mysql can read username and password from my.cnf like shown below,

[mysql]
user=root
password=myrootpassword

However. if I have to read password from another file from inside this my.cnf, how would I do that? For example as shown below,

[mysql]
user=root
password=/path/to/a/file/containing/password

Thanks in advance!

我知道,MySQL可以读取my.cnf如下所示的用户名和密码,

[mysql]
user=root
password=myrootpassword

然而.如果我要从另一个文件从这里面找到读取密码,我该怎么做?例如如下所示,

[mysql]
user=root
password=/path/to/a/file/containing/password

先谢谢了。

answer1: 回答1:

You can use directive !include for specifying another configuration file in MySQL .cnf files - something like:

!include /path/to/a/file/containing/password.cnf

and then provide password within that specified file.

See more here - http://dev.mysql.com/doc/refman/5.7/en/option-files.html

你可以使用指令!包括MySQL指定另一个配置文件。文件-像:

!include /path/to/a/file/containing/password.cnf

然后在指定文件中提供密码。

看到这里http://dev.mysql.com/doc/refman/5.7/en/option-files.html

mysql