MySQL 二进制日志

MySQL 二进制日志

我的服务器告诉我二进制日志记录已禁用。当我执行 时mysqladmin 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,然后 a service mysqld start,然后mysqladmin variables。但是它说log-bin | OFF?我做错了什么?顺便说一下,我们使用的是 MySQL 5.5.18-ccl。

答案1

确保 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

答案2

指定:

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

干杯

相关内容