在/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)
我在Google上搜索了“ my.cnf无效”,并得到了“对my.cnf的更改无效(Ubuntu 16.04,mysql 5.6)” Changes to my.cnf don't take effect (Ubuntu 16.04, mysql 5.6)
我已经测试了两个答案。但是,当我使用sudo service mysql start
启动mysql时,总是会出现此错误:
/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.
我已经花了两天时间寻找答案,但仍然找不到任何帮助。有人可以帮我吗?谢谢!
答案 0 :(得分:0)
重新安装MySQL
根据清洁MySQL: https://askubuntu.com/questions/172514/how-do-i-uninstall-mysql
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
以及https://www.jianshu.com/p/c76b31df5d09
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
通过sudo apt-get install mysql-server-5.6
使my.cnf
中的更改生效
Keeth(用户:20588)的第二个回答 Changes to my.cnf don't take effect (Ubuntu 16.04, mysql 5.6)
通过编辑binlog
/etc/mysql/my.cnf
[mysqld]
log_bin=mysql-bin
binlog_format=ROW
server-id=11