是否有一个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
其他回答
你可以在终端上运行查找。
find / -name my.cnf
如果你在VPS中,并试图在已经运行的服务器上编辑my.cnf,你可以尝试:
ps aux | grep mysql
您将显示mysql命令正在运行的参数以及——defaults-file指向的位置
请注意,您的服务器可能运行多个MySQL/MariaDB服务器。如果您看到一行没有——defaults-file参数,该实例可能正在从mysqladmin上提到的.cnf中检索配置——帮助其他人指出。
我安装xampp bundle与apache, php和mysql在ubuntu。my.cnf文件位于/opt/lampp/etc/文件夹中。希望它能帮助到一些人。
对于Ubuntu 20.04.4 LTS上的MariaDB 10.5 (Focal Fossa):
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
你可以使用:
locate my.cnf
whereis my.cnf
find . -name my.cnf