FreeBSD的默认MySQL basedir,port等,用于my.cnf

我正在使用FreeBSD 9.2服务器,并运行mysqltuner.pl来检查MySQL的内存和caching需求。 现在我需要添加一个my.cnf文件到FreeBSD,所以它使用它来代替auto cnf文件。

我可以这样复制my-default.cnf

cp /usr/local/share/mysql/my-default.cnf /usr/local/etc/my.cnf

然后my.cnf会加载。

my-default.cnf文件显示了这些值(这将会传递给my.cnf ):

 # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # *the above innodb line I can set* # *But where do I get the values below?* # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # socket = ..... 

我在哪里得到以上的价值? 我知道他们必须来自当前的MySQL服务器,但我如何find这些设置?

如果这个问题在https://dba.stackexchange.com/ ?

你可以通过login到mysql来获取你当前的configuration并运行查询

 SHOW VARIABLES; 

要search特定的configuration,可以使用SQL语法。 例如要知道当前datadir使用:

 SHOW VARIABLES LIKE '%datadir%'; 

参考: 官方的MySQL文档

一般来说,你不需要定义这些参数,因为它们很难被编译到作为FreeBSD端口的mysql中。 您必须更改负责数据库引擎曲调的参数。

这是我的configuration例如

 [client] port = ***** [mysqld] port = ***** skip-external-locking key_buffer_size = 128M max_allowed_packet = 1M table_open_cache = 512 join_buffer_size = 2M sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 32M query_cache_limit = 2M query_cache_size = 32M thread_cache_size = 4 thread_concurrency = 8 event-scheduler = ON server-id = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout 

所有我改变的是tcp端口,以避免愚蠢的h4xor敲标准3306

我知道这个post已经有几年了,自从FreeBSD 9.2以后,很多东西都发生了变化(实际上是2017年11月的版本11.1),你可以findmy.cnf文件

 /usr/local/etc/mysql