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


当前回答

MySQL配置文件:

/etc/my.cnf

其他回答

请注意,尽管mariadDB从其他答案中列出的各种my.cnf文件加载配置详细信息,但它也可以从其他具有不同名称的文件加载配置详细信息。

这意味着如果您对my.cnf文件中的一个进行了更改,它可能会被另一个具有不同名称的文件覆盖。要使更改生效,您需要在正确的(最后加载的)配置文件中更改它-或者,可能在所有配置文件中更改它。

那么如何找到所有可能加载的配置文件呢?不要寻找my.cnf文件,试着运行:

grep -r datadir /etc/mysql/

这将找到所有提到datadir的地方。在我的例子中,它产生了这样的答案:

/etc/mysql/mariadb.conf.d/50-server.cnf:datadir     = /var/lib/mysql 

当我编辑该文件(/etc/mysql/mariadb.conf.d/50-server.cnf)来更改datadir的值时,它起作用了,而在my.cnf中更改它不起作用。所以无论你想改变什么选择,试着用这种方式来寻找。

对我来说,这是我有“ENGINE=MyISAM”类型的表,一旦我改变它为“ENGINE=InnoDB”它工作了:) 在PhpMyAdmin在Azure应用程序服务:)

对于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.

另一个选项是使用whereis命令。

例如:my.cnf在哪里

如果你用的是安装了Homebrew的Mac电脑,那就用吧

编译mysql信息

你会看到

$ brew info mysql
mysql: stable 5.6.13 (bottled)
http://dev.mysql.com/doc/refman/5.6/en/
Conflicts with: mariadb, mysql-cluster, percona-server
/usr/local/Cellar/mysql/5.6.13 (9381 files, 354M) *

最后一行是MySQL文档中的INSTALLERDIR