Mysql

MariaDB 忽略 /etc/my.cnf

  • January 19, 2020

我要更改的變數是innodb_buffer_pool_size。如下所示,設置為 512M。但SELECT @@innodb_buffer_pool_size;返回 134217728。

當我執行時:/usr/libexec/mysqld --help --verbose

我得到的配置是:

Default options are read from the following files in the given order: 
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
  1. /etc/mysql/my.cnf - 不存在
  2. /etc/my.cnf - 如下所示
  3. ~/.my.cnf - 當我cd ~/被帶到不存在 my.cnf 文件的 /root 時。mysql是否以root身份執行,是否會被帶到同一目錄?我怎麼知道?

這是我的.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

skip-networking

innodb_thread_concurrency = 6
innodb_flush_log_at_trx_commit = 2
thread_concurrency = 12 
table_cache = 1024
query_cache_size = 64M
query_cache_type=1
query_cache_limit = 4M
expire_logs_days=10
max_binlog_size=100M
join_buffer_size = 8M
tmp_table_size =256M  
max_allowed_packet = 2M
thread_stack = 192K
thread_cache_size = 32
thread_concurrency = 4
table_open_cache  = 4096
myisam-recover=BACKUP
max_connections        = 2500
max_heap_table_size = 256M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
innodb_additional_mem_pool_size = 8M
innodb_log_buffer_size = 4M
innodb_log_file_size = 128M
innodb_log_files_in_group = 2
innodb_flush_log_at_trx_commit = 0
innodb_buffer_pool_size = 512M
innodb_data_home_dir = /var/lib/mysql/
innodb_data_file_path = ibdata1:256M:autoextend
innodb_autoextend_increment=512
slow_query_log = Off
slow_query_log_file = /var/www/html/log/mysql/slow-queries.log
long_query_time = 2
innodb_file_per_table = 1 

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid


[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

[isamchk]
key_buffer              = 32M

我也在觀察同樣的問題,我建議請檢查 my.cnf 提到的路徑和 my.cnf 提到的路徑的權限。

遲到的答案,但是:檢查/etc/init.d/mysql

Mariadb 仍然(18.04)安裝了一個初始化腳本

MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"

和 mysqladmin 聲稱讀取/etc/my.cnf, /etc/mysql/my.cnf,這是不正確的。只需刪除其中的--defaults-file=/etc/mysql/debian.cnf部分/etc/init.d/mysql

引用自:https://dba.stackexchange.com/questions/101015