是否有一个MySQL命令来定位my.cnf配置文件,类似于PHP的phpinfo()定位它的PHP .ini?
当前回答
仅回答MySQL工作台用户,
其他回答
另一个选项是使用whereis命令。
例如:my.cnf在哪里
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
如果你在VPS中,并试图在已经运行的服务器上编辑my.cnf,你可以尝试:
ps aux | grep mysql
您将显示mysql命令正在运行的参数以及——defaults-file指向的位置
请注意,您的服务器可能运行多个MySQL/MariaDB服务器。如果您看到一行没有——defaults-file参数,该实例可能正在从mysqladmin上提到的.cnf中检索配置——帮助其他人指出。
你可以使用:
locate my.cnf
whereis my.cnf
find . -name my.cnf
所有很棒的建议,在我的情况下,我没有在任何这些位置找到它,但在/usr/share/mysql,我有一个RHEL虚拟机,我安装了mysql5.5