我在 Ubuntu 15.04 上使用 MySql 社区服务器 5.6,我有 /etc/mysql/my.cnf(没有其他配置文件)。我对其进行了更改并重新启动了 MySql。当我使用这样的查询时
SELECT @@key_buffer_size
(或 my.cnf 文件中的其他配置)它返回的值与 my.cnf 中的值相同。我试图将内存消耗降至最低,但经过所有努力,MySql 仍然启动了约 20 个线程并消耗了约 370MB。
您能帮我找出为什么 MySql 不使用(但看到)配置吗?
my.cnf(完整文件内容)为:
[mysql]
port = 3306
socket = /run/mysqld/mysqld.sock
[mysqld]
user = mysql
default_storage_engine = InnoDB
socket = /run/mysqld/mysqld.sock
pid_file = /var/lib/mysql/mysql.pid
myisam_recover = FORCE,BACKUP
max_allowed_packet = 16M
max_connect_errors = 10
datadir = /var/lib/mysql/
log_bin = /var/lib/mysql/mysql_bin
expire_logs_days = 5
sync_binlog = 1
binlog_cache_size = 4K
binlog_stmt_cache_size = 4K
log_error = /var/lib/mysql/mysql_error.log
log_queries_not_using_indexes = 1
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/mysql_slow.log
tmp_table_size = 1K
max_heap_table_size = 16K
query_cache_type = 0
query_cache_size = 4M
query_cache_limit = 256K
thread_stack = 128K
open_files_limit = 65535
table_definition_cache = 1K
table_open_cache = 2K
max_connections = 30
key_buffer_size = 8M
thread_cache_size = 0
host_cache_size = 0
sort_buffer_size = 32K
read_buffer_size = 8200
read_rnd_buffer_size = 8200
bulk_insert_buffer_size = 0
join_buffer_size = 128
net_buffer_length = 1K
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_log_file_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_buffer_pool_size = 5M
innodb_log_buffer_size = 256K
innodb_sort_buffer_size = 64K
innodb_ft_cache_size = 1600K
innodb_ft_total_cache_size = 32M
答案1
最后,我终于解决了这个问题。5.6.10版本的bug
我找到了一个解决方案:评论行
table_definition_cache = 1K
虽然我使用的是 5.6.27 版本,但它运行良好。现在 MySql 占用不到 70MB。