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


当前回答

对我来说,这是我有“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.

没有MySQL内部命令来跟踪这一点,这有点太抽象了。该文件可能位于5个(或更多)位置,并且它们都是有效的,因为它们加载级联。

/etc/my.cnf /etc/mysql/my.cnf $ MYSQL_HOME / my.cnf [datadir]。/ my . cnf中所做 ~ / .my.cnf

这些是MySQL查看的默认位置。如果它发现不止一个,它将加载它们中的每一个&值相互覆盖(在列出的顺序,我认为)。此外,——defaults-file参数可以覆盖整个内容,所以…基本上,这是一件非常痛苦的事。

但由于它太令人困惑,很有可能它只是在/etc/my.cnf.中

(如果你只是想看值:SHOW VARIABLES,但你需要权限这样做。)


运行mysql——help,你会看到:

默认选项按照指定顺序从以下文件中读取:/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

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

ps aux | grep mysql

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

请注意,您的服务器可能运行多个MySQL/MariaDB服务器。如果您看到一行没有——defaults-file参数,该实例可能正在从mysqladmin上提到的.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

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