Linux

MySQL 二進制日誌

  • July 19, 2012

我的伺服器告訴我二進制日誌記錄已禁用。當我做 amysqladmin variables時,我看到了這個:log_bin | OFF. 這是我的配置文件:

[mysqld]
# These are some standard (Plesk) options needed:
datadir             = /var/lib/mysql
socket              = /var/lib/mysql/mysql.sock
user                = mysql
old_passwords           = 1

# Some general options:
default_storage_engine      = MyISAM
#   We want to make sure eventual data loss is handled correctly:
myisam_recover          = FORCE,BACKUP

# Some security things, to avoid overloading:
max_allowed_packet      = 16M
max_connect_errors      = 1000000

# The important stuff, caching and performance tweaks:
max_connections         = 100
key_buffer_size         = 50M
read_buffer_size        = 2M
sort_buffer_size        = 5M
myisam_use_mmap         = 1
tmp_table_size          = 16M
max_heap_table_size     = 16M
query_cache_type        = 1
query_cache_size        = 64M
thread_cache_size       = 25
open_files_limit        = 65535
table_definition_cache      = 1024
table_open_cache        = 1024

# Although InnoDB is not used, some default optimization options:
innodb_buffer_pool_size     = 32M
innodb_data_file_path       = ibdata1:10M:autoextend
innodb_flush_log_at_trx_commit  = 2

# And finally some logging:
log_error           = /var/lib/mysql/mysql-error.log
log_queries_not_using_indexes   = 0
slow_query_log          = 1
slow_query_log_file     = /var/lib/mysql/mysql-slow.log

# Master
log-bin=/var/lib/mysql/mysql-bin 
server-id = 1
innodb_flush_log_at_trx_commit=1
sync_binlog=1

所以,我做了mysqladmin shutdown,然後是service mysqld start和之後mysqladmin variables。但它說log-bin | OFF?我究竟做錯了什麼?順便說一下,我們使用的是 MySQL 5.5.18-ccl。

確保 mysql 是 /var/lib/mysql 的所有者,如下所示:

cd /var/lib
service mysql stop
chown -R mysql:mysql mysql 
service mysql start

要檢查的另一件事是是否存在另一個 my.cnf

嘗試以下

cd /var/lib/mysql
ls -l my.cnf

如果存在 my.cnf 文件,那麼您已經找到了罪魁禍首。只需重命名文件

mv /var/lib/mysql/my.cnf /var/lib/mysql/my.cnf_old

進而service mysql restart

指定:

log-bin-index = /var/lib/mysql/mysql-bin.index

乾杯

引用自:https://serverfault.com/questions/408461