对于自制mysql安装,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时指定要读取的其他文件。
其他回答
有一种方法可以知道:
sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf
服务器版本:8.0.19 Homebrew。macOS Catalina 10.15.5,通过Homebrew安装MySQL在这里找到这个文件:
/usr/local/etc/my.cnf
这个解决方案有帮助:)
由于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.
我相信答案是否定的。在~/.my.cnf或/usr/local/etc中安装一个似乎是首选的解决方案。
如果您使用的是mac m1 (Apple silicon), my.cnf位于
/opt/homebrew/etc/my.cnf
也可以通过mysql——help找到
推荐文章
- 如何关闭mysql密码验证?
- MySQL区分大小写查询
- MySQL数据库表中的最大记录数
- 原则-如何打印出真正的sql,而不仅仅是准备好的语句?
- PHP/MySQL插入一行然后获取id
- 如何从命令行通过mysql运行一个查询?
- 如何从命令行在windows中找到mysql数据目录
- 如何找到MySQL的根密码
- 如何改变字符集(和排序)在整个数据库?
- mySQL:: insert到表,数据从另一个表?
- 重复键忽略?
- Homebrew:以新的formula@version格式列出可用版本
- 将表从一个数据库复制到另一个数据库的最简单方法?
- 如何通过查询在MySQL中获得数据库结构?
- MySQL删除表中的所有行,并将ID重置为零