对于自制mysql安装,my.cnf在哪里?它安装了吗?


当前回答

在我的系统里是这样的

nano /usr/local/etc/my.cnf.default 

作为模板和

nano /usr/local/etc/my.cnf

为工作。

其他回答

在我的系统里是这样的

nano /usr/local/etc/my.cnf.default 

作为模板和

nano /usr/local/etc/my.cnf

为工作。

默认情况下没有my.cnf。因此,MySQL以所有默认设置启动。如果您想创建自己的my.cnf来覆盖任何默认值,请将其放在/etc/my.cnf

同样,你也可以运行mysql——help来查找上面列出的conf位置。

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/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.

正如你所看到的,还有一些选项可以绕过conf文件,或者当你在命令行上调用mysql时指定要读取的其他文件。

在Homebrew的情况下,mysql也会在它的Cellar目录中查找my.cnf,例如:

/usr/local/Cellar/mysql/5.7.21/my.cnf

对于这种情况,人们更喜欢将配置文件保持在接近二进制文件的位置——如果缺少的话,在这里创建my.cnf。

修改后重启mysql:

brew services restart mysql

run

Sudo查找/ -name my.cnf

通常第一个结果是正确的。 应该在

/ usr / local / etc /

由于mysql——help显示了一个文件列表,我发现将结果管道到ls来查看它们中的哪些存在是有用的:

$ mysql --help | grep /my.cnf | xargs ls
ls: /etc/my.cnf: No such file or directory
ls: /etc/mysql/my.cnf: No such file or directory
ls: ~/.my.cnf: No such file or directory
/usr/local/etc/my.cnf

对于我的(安装了Homebrew) MySQL 5.7,文件似乎在/usr/local/etc/my.cnf.