安装mysql后,系统中会有多个my.cnf文件。
使用 locate my.cnf 命令可以列出所有的my.cnf文件:
> locate my.cnf/etc/my.cnf/usr/local/mysql/mysql-test/include/default_my.cnf/usr/local/mysql/mysql-test/suite/federated/my.cnf/usr/local/mysql/mysql-test/suite/ndb/my.cnf/usr/local/mysql/mysql-test/suite/ndb_big/my.cnf/usr/local/mysql/mysql-test/suite/ndb_binlog/my.cnf/usr/local/mysql/mysql-test/suite/ndb_ddl/my.cnf/usr/local/mysql/mysql-test/suite/ndb_memcache/my.cnf/usr/local/mysql/mysql-test/suite/ndb_rpl/my.cnf/usr/local/mysql/mysql-test/suite/ndb_team/my.cnf/usr/local/mysql/mysql-test/suite/ndbcluster/my.cnf/usr/local/mysql/mysql-test/suite/rpl/my.cnf/usr/local/mysql/mysql-test/suite/rpl/extension/bhs/my.cnf/usr/local/mysql/mysql-test/suite/rpl_ndb/my.cnf
> ps aux | grep mysql | grep 'my.cnf'
命令输出结果中的–defaults-file,就是mysql启动加载的配置文件。如果没有输入结果,则表示没有设置使用指定目录的my.cnf。
> mysql --help|grep 'my.cnf'order of preference, my.cnf, $MYSQL_TCP_PORT,/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
mysql --help|grep 'my.cnf'
查看mysql默认读取的my.cnf,按照从前到后的优先级排序,前面的不存在,则读取后面的。通常配置在/etc/my.cnf。
来源地址:https://blog.csdn.net/qq_39153720/article/details/130838051