是否有一个MySQL命令来定位my.cnf配置文件,类似于PHP的phpinfo()定位它的PHP .ini?
当前回答
你必须根据你的MySQL版本查找不同的位置。
mysqld --help -verbose | grep my.cnf
For Homebrew:
/usr/local/Cellar/mysql/8.0.11/bin/mysqld (mysqld 8.0.11)
Default possible locations:
/etc/my.cnf
/etc/mysql/my.cnf
~/.my.cnf
Found mine here:
/usr/local/etc/my.cnf
其他回答
这可能有用:
strace mysql ";" 2>&1 | grep cnf
在我的机器上输出:
stat64("/etc/my.cnf", 0xbf9faafc) = -1 ENOENT (No such file or directory)
stat64("/etc/mysql/my.cnf", {st_mode=S_IFREG|0644, st_size=4271, ...}) = 0
open("/etc/mysql/my.cnf", O_RDONLY|O_LARGEFILE) = 3
read(3, "# /etc/mysql/my.cnf: The global "..., 4096) = 4096
stat64("/home/xxxxx/.my.cnf", 0xbf9faafc) = -1 ENOENT (No such file or directory)
因此,看起来/etc/mysql/my.cnf是一个,因为它的stat64()和read()是成功的。
在Ubuntu上(直接编辑):
$ sudo nano /etc/mysql.conf.d/mysqld.cnf
你可以在终端上运行查找。
find / -name my.cnf
我不知道你是如何在Linux环境下安装MySQL的,但你检查过吗?
/etc/my.cnf
MySQL配置文件:
/etc/my.cnf