是否有一个MySQL命令来定位my.cnf配置文件,类似于PHP的phpinfo()定位它的PHP .ini?


当前回答

你可以使用:

locate my.cnf
whereis my.cnf
find . -name my.cnf

其他回答

仅回答MySQL工作台用户,

如果你在VPS中,并试图在已经运行的服务器上编辑my.cnf,你可以尝试:

ps aux | grep mysql

您将显示mysql命令正在运行的参数以及——defaults-file指向的位置

请注意,您的服务器可能运行多个MySQL/MariaDB服务器。如果您看到一行没有——defaults-file参数,该实例可能正在从mysqladmin上提到的.cnf中检索配置——帮助其他人指出。

找到了我的

mysqld --help --verbose | grep my.cnf

在Ubuntu上(直接编辑):

$ sudo nano /etc/mysql.conf.d/mysqld.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()是成功的。