0

在 /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.

我花了两天时间寻找答案,但仍然没有找到任何有用的东西。有人可以帮我吗?谢谢!

4

1 回答 1

0
  1. 重新安装 MySQL

    根据: https ://askubuntu.com/questions/172514/how-do-i-uninstall-mysql 清理 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

  2. 使更改my.cnf生效

    Keeth(user:20588) 对 my.cnf 的更改未生效的第二个回答(Ubuntu 16.04,mysql 5.6)

  3. binlog通过编辑配置/etc/mysql/my.cnf

        [mysqld]
        log_bin=mysql-bin
        binlog_format=ROW
        server-id=11
    
于 2018-10-10T09:23:03.287 回答