本文介绍了如何找到 MySQL my.cnf 位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a MySQL command to locate the my.cnf configuration file, similar to how PHP's phpinfo() locates its php.ini?

推荐答案

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

There is no internal MySQL command to trace this, it's a little too abstract. The file might be in 5 (or more?) locations, and they would all be valid because they load cascading.

  • /etc/my.cnf
  • /etc/mysql/my.cnf
  • $MYSQL_HOME/my.cnf
  • [数据目录]/my.cnf
  • ~/.my.cnf

这些是 MySQL 查看的默认位置.如果它找到多个,它将​​加载它们中的每一个 &值相互覆盖(我认为按照列出的顺序).此外,--defaults-file 参数可以覆盖整个内容,所以......基本上,这是一个巨大的痛苦.

Those are the default locations MySQL looks at. If it finds more than one, it will load each of them & values override each other (in the listed order, I think). Also, the --defaults-file parameter can override the whole thing, so... basically, it's a huge pain in the butt.

但由于它如此混乱,很有可能它就在/etc/my.cnf 中.

But thanks to it being so confusing, there's a good chance it's just in /etc/my.cnf.

(如果您只想查看值:SHOW VARIABLES,但您需要获得权限才能这样做.)

(if you just want to see the values: SHOW VARIABLES, but you'll need the permissions to do so.)

这篇关于如何找到 MySQL my.cnf 位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 05:01