简体   繁体   English

mysql-设置〜/ .my.cnf位置?

[英]mysql - set ~/.my.cnf location?

Is it possible to specify which .my.cnf file mysql client should use? 是否可以指定mysql客户端应使用哪个.my.cnf文件? I have 2 mysql instances running on different ports and want to only need to specify a filename with credentials. 我有2个在不同端口上运行的mysql实例,只需要指定一个带有凭据的文件名即可。

As documented under Command-Line Options that Affect Option-File Handling : 影响选项文件处理的命令行选项所述

When specifying file names, you should avoid the use of the “~” shell metacharacter because it might not be interpreted as you expect. 指定文件名时,应避免使用“〜” shell元字符,因为它可能无法按预期方式进行解释。

  • --defaults-extra-file= file_name

    Read this option file after the global option file but (on Unix) before the user option file. 在全局选项文件之后但在用户选项文件之前(在Unix上)读取此选项文件。 If the file does not exist or is otherwise inaccessible, the program exits with an error. 如果文件不存在或无法访问,则程序退出并出现错误。 file_name is interpreted relative to the current directory if given as a relative path name rather than a full path name. file_name作为相对路径名而不是完整路径名给出,则相对于当前目录进行解释。

  • --defaults-file= file_name

    Use only the given option file. 仅使用给定的选项文件。 If the file does not exist or is otherwise inaccessible, the program exits with an error. 如果文件不存在或无法访问,则程序退出并出现错误。 file_name is interpreted relative to the current directory if given as a relative path name rather than a full path name. file_name作为相对路径名而不是完整路径名给出,则相对于当前目录进行解释。

  • --defaults-group-suffix= str

    If this option is given, the program reads not only its usual option groups, but also groups with the usual names and a suffix of str . 如果指定了此选项,则程序不仅会读取其常规选项组,还会读取具有常规名称和后缀str For example, the mysql client normally reads the [client] and [mysql] groups. 例如, mysql客户端通常读取[client][mysql]组。 If the --defaults-group-suffix=_other option is given, mysql also reads the [client_other] and [mysql_other] groups. 如果给出了--defaults-group-suffix=_other选项,则mysql也会读取[client_other][mysql_other]组。

Note that " to work properly, each of these options must be given before other options ". 请注意,“ 要正常工作,必须在其他选项之前给出每个选项 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM