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


当前回答

尝试运行mysqld——help——verbose | grep my.cnf | tr " " "\n"

输出类似于

/etc/my.cnf
/etc/mysql/my.cnf
/usr/local/etc/my.cnf
~/.my.cnf

其他回答

仅回答MySQL工作台用户,

如果您正在使用MAMP,请访问模板> MySQL (my.cnf) > [version]

如果您正在运行MAMP无窗口,您可能需要使用customize按钮定制工具栏。

mysql --help | grep /my.cnf | xargs ls

会告诉你my.cnf在Mac/Linux上的位置吗

ls: cannot access '/etc/my.cnf': No such file or directory
ls: cannot access '~/.my.cnf': No such file or directory
 /etc/mysql/my.cnf

在本例中,它在/etc/mysql/my.cnf中

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

在本例中,它位于/usr/local/etc/my.cnf

Ubuntu 16: /etc/mysql/mysql.conf.d/mysqld.cnf

在Ubuntu上(直接编辑):

$ sudo nano /etc/mysql.conf.d/mysqld.cnf