我试图在命令行上使用--defaults-file选项登录mysql:
$ mysql --defaults-file ~/mycnf.cnf
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
mysql: unknown option '--defaults-file'
Run Code Online (Sandbox Code Playgroud)
但是这个选项列在帮助中:
$ mysql --help
...
Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-file=# Only read default options from the given file #.
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?这是mysql --version的输出
$ mysql --version
mysql Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (x86_64) using readline 5.1
Run Code Online (Sandbox Code Playgroud)
我想在我面临的类似情况中为这个问题添加另一个答案.
在我的例子中,命令类似于:
/path/to/mysqld_safe start --defaults-file=/path/to/my.cnf --other-options-here
Run Code Online (Sandbox Code Playgroud)
和mysql会抱怨
unknown variable '--defaults-file=/path/to/my.cnf'
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我不得不"删除" start命令,使行读取如下:
/path/to/mysqld_safe --defaults-file=/path/to/my.cnf --other-options-here
Run Code Online (Sandbox Code Playgroud)
然后mysql最终会开始使用指定的配置文件.
它应该是:
mysql --defaults-file=~/mycnf.cnf
Run Code Online (Sandbox Code Playgroud)
你错过了=.
就我而言,问题是参数放错了位置。
该--console参数应该是最后一个...
我最初的看法:
mysqld --console --defaults-file="path-to-ini/my.ini"
虽然应该运行此命令:
mysqld --defaults-file="path-to-ini/my.ini" --console
| 归档时间: |
|
| 查看次数: |
14090 次 |
| 最近记录: |