是否有一个MySQL命令来定位my.cnf配置文件,类似于PHP的phpinfo()定位它的PHP .ini?
当前回答
这可能有用:
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()是成功的。
其他回答
如果你使用的是Debian/Ubuntu系统,并且已经配备了现代版本的数据库(从5.7以上,mysql 8也适用),找到我发现的实际.cnf文件的最佳方法是:
sudo update-alternatives --config my.cnf
你应该看到如下输出:
There are 3 choices for the alternative my.cnf (providing /etc/mysql/my.cnf).
Selection Path Priority Status
------------------------------------------------------------
0 /etc/mysql/mariadb.cnf 500 auto mode
1 /etc/mysql/mariadb.cnf 500 manual mode
2 /etc/mysql/my.cnf.fallback 100 manual mode
* 3 /etc/mysql/mysql.cnf 300 manual mode
在/etc/mysql/mysql.cnf中有两行值得注意:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
MySQL会在/etc/ MySQL /conf目录下寻找所有的.cnf文件。/etc/mysql/mysql.conf. D /
调优快乐!
尝试运行mysqld——help——verbose | grep my.cnf | tr " " "\n"
输出类似于
/etc/my.cnf
/etc/mysql/my.cnf
/usr/local/etc/my.cnf
~/.my.cnf
try
mysql --verbose --help | grep -A 1 "Default options"
这可能有用:
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