在 /etc/mysql/my.cnf 中:
[mysqld]
log_bin=mysql-bin
binlog_format=ROW
server-id=11
然后在mysql客户端上:
mysql> show variables like '%binlog%';
+-----------------------------------------+----------------------+
| Variable_name | Value |
+-----------------------------------------+----------------------+
| binlog_cache_size | 32768 |
| binlog_checksum | CRC32 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_format | STATEMENT |
| binlog_max_flush_queue_time | 0 |
| binlog_order_commits | ON |
| binlog_row_image | FULL |
| binlog_rows_query_log_events | OFF |
| binlog_stmt_cache_size | 32768 |
| innodb_api_enable_binlog | OFF |
| innodb_locks_unsafe_for_binlog | OFF |
| max_binlog_cache_size | 18446744073709547520 |
| max_binlog_size | 1073741824 |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| sync_binlog | 0 |
+-----------------------------------------+----------------------+
15 rows in set (0.00 sec)
我用谷歌搜索“my.cnf 不生效”并得到“对 my.cnf 的更改不生效(Ubuntu 16.04,mysql 5.6)” 对 my.cnf 的更改不生效(Ubuntu 16.04,mysql 5.6)
我已经测试了两个答案。但是当我用 mysql 启动时sudo service mysql start
,总是会出现这个错误:
/etc/init.d/mysql[27197]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
/etc/init.d/mysql[27197]: [61B blob data]
/etc/init.d/mysql[27197]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
/etc/init.d/mysql[27197]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
/etc/init.d/mysql[27197]:
mysql[26527]: ...fail!
systemd[1]: mysql.service: Control process exited, code=exited status=1
systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
我花了两天时间寻找答案,但仍然没有找到任何有用的东西。有人可以帮我吗?谢谢!