ewa*_*she 267
自制软件mysql包含安装的support-files文件夹中的示例配置文件.
ls $(brew --prefix mysql)/support-files/my-*
Run Code Online (Sandbox Code Playgroud)
如果您需要更改默认设置,可以使用其中一个作为起点.
cp $(brew --prefix mysql)/support-files/my-default.cnf /usr/local/etc/my.cnf
Run Code Online (Sandbox Code Playgroud)
正如@rednaw指出的那样,自制的MySQL安装很可能就在这里,/usr/local所以不应该将my.cnf文件添加到系统/etc文件夹中,所以我更改了将文件复制到的命令/usr/local/etc.
如果您使用的是MariaDB而不是MySQL,请使用以下命令:
cp $(brew --prefix mariadb)/support-files/my-small.cnf /usr/local/etc/my.cnf
Run Code Online (Sandbox Code Playgroud)
Jer*_*con 253
默认情况下没有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.
Run Code Online (Sandbox Code Playgroud)
如您所见,还有一些选项可以绕过conf文件,或指定在命令行调用mysql时要读取的其他文件.
Joh*_*hir 28
一种方法可以找到:
sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf
Run Code Online (Sandbox Code Playgroud)
Sim*_*mba 25
添加另一个答案原因
mysql,而不是手动安装的 MySQL,因此有更直接的方法来查找conf.d文件。在安装过程中,Homebrew 将其my.cnf复制到以下位置
/usr/local/etc/my.cnf适用于 x86 Mac/opt/homebrew/etc/my.cnf适用于 M1 MacHomebrew 选择/usr/local, 或/opt/homebrew来存储包,因此默认的conf文件不存储在/etc/but/usr/local/etc或中/opt/homebrew/etc。
事实上,自制程序在从源代码-DSYSCONFDIR=编译期间更改了(默认配置位置)标志。mysql
简短的回答:运行brew info mysql并检查提示。
推荐的方式是brew services start mysql,使用launchd来管理服务。(launchd被视为systemdmacOS 上的替代方案)
对于任何想要手动启动它的人来说,mysql.start无需任何选项就足以启动该服务。(mysql.start是提供的脚本来mysql帮助启动服务)
naa*_*ter 16
什么都没有帮助我 - 我无法覆盖/etc/my.cnf文件中的设置.所以我像John建议的那样搜索/sf/answers/558188011/
sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf
Run Code Online (Sandbox Code Playgroud)
它发现了另一个my.cnf
/usr/local/Cellar/mysql/5.6.21/my.cnf
Run Code Online (Sandbox Code Playgroud)
更改此文件对我有用!不要忘记重启启动代理:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Run Code Online (Sandbox Code Playgroud)
Fus*_*are 14
在我的系统中它是
nano /usr/local/etc/my.cnf.default
Run Code Online (Sandbox Code Playgroud)
作为模板和
nano /usr/local/etc/my.cnf
Run Code Online (Sandbox Code Playgroud)
工作.
lui*_*9mx 10
在你的shell类型上 my_print_defaults --help
在结果的底部,您应该能够看到服务器从中读取配置的文件.它打印的内容如下:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
Run Code Online (Sandbox Code Playgroud)
Emi*_*röm 10
由于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
Run Code Online (Sandbox Code Playgroud)
对于我的(Homebrew安装)MySQL 5.7,似乎文件已打开/usr/local/etc/my.cnf.
您可以找到my.cnf特定包提供文件的位置,例如
brew list mysql # or: mariadb
Run Code Online (Sandbox Code Playgroud)
除了验证该文件是否被读取外,您还可以运行:
sudo fs_usage | grep my.cnf
Run Code Online (Sandbox Code Playgroud)
这将实时显示与该文件相关的文件系统活动。
服务器版本:8.0.19 Homebrew。macOS Catalina 10.15.5 并通过 Homebrew 安装 MySQL。在这里找到这个文件:
/usr/local/etc/my.cnf
Run Code Online (Sandbox Code Playgroud)
这个解决方案有帮助:)
| 归档时间: |
|
| 查看次数: |
145592 次 |
| 最近记录: |