mysql> select version();
±----------+
| version() |
±----------+
| 5.7.25 |
±----------+
1 row in set (0.00 sec)
mysql> show variables like’%log_bin%’;
±--------------------------------±------+
| Variable_name | Value |
±--------------------------------±------+
| log_bin | OFF |
| log_bin_basename | |
| log_bin_index | |
| log_bin_trust_function_creators | OFF |
| log_bin_use_v1_row_events | OFF |
| sql_log_bin | ON |
±--------------------------------±------+
6 rows in set (0.01 sec)
#修改/etc/my.cnf 启动binlog
[root@linux_64 mysqldata]# vi /etc/my.cnf
1 # For advice on how to change settings please see
2 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
3 [client]
4 socket=/mysqldata/mysql/mysql.sock
5
6 [mysqld]
7 #
8 # Remove leading # and set to the amount of RAM for the most important data
9 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
10 # innodb_buffer_pool_size = 128M
11 #
12 # Remove leading # to turn on a very important data integrity option: logging
13 # changes to the binary log between backups.
14 # log_bin
15 #
16 # Remove leading # to set options mainly useful for reporting servers.
17 # The server defaults are faster for transactions and fast SELECTs.
18 # Adjust sizes as needed, experiment to find the optimal values.
19 # join_buffer_size = 128M
20 # sort_buffer_size = 2M
21 # read_rnd_buffer_size = 2M
22 datadir=/mysqldata/mysql
23 socket=/mysqldata/mysql/mysql.sock
24 log_bin=/mysqldata/log_bin.00001 **//添加**
25
26 # Disabling symbolic-links is recommended to prevent assorted security risks
27 symbolic-links=0
28
29 log-error=/var/log/mysqld.log
30 pid-file=/var/run/mysqld/mysqld.pid
#启动mysql
[root@linux_64 mysqldata]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
#查看mysql错误日志并没有任何报错
2019-05-28T05:59:35.664967Z 0 [Note] InnoDB: Starting shutdown…
2019-05-28T05:59:35.765738Z 0 [Note] InnoDB: Dumping buffer pool(s) to /mysqldata/mysql/ib_buffer_pool
2019-05-28T05:59:35.766007Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 190528 13:59:35
2019-05-28T05:59:37.295237Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2540222
2019-05-28T05:59:37.297884Z 0 [Note] InnoDB: Removed temporary tablespace data file: “ibtmp1”
2019-05-28T05:59:37.297911Z 0 [Note] Shutting down plugin ‘MEMORY’
2019-05-28T05:59:37.297923Z 0 [Note] Shutting down plugin ‘PERFORMANCE_SCHEMA’
2019-05-28T05:59:37.297978Z 0 [Note] Shutting down plugin ‘MRG_MYISAM’
2019-05-28T05:59:37.297990Z 0 [Note] Shutting down plugin ‘sha256_password’
2019-05-28T05:59:37.297998Z 0 [Note] Shutting down plugin ‘mysql_native_password’
2019-05-28T05:59:37.298291Z 0 [Note] Shutting down plugin ‘binlog’
2019-05-28T05:59:37.298672Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
#重新修改/etc/my.cnf文件,添加server-id
[root@linux_64 mysqldata]# vi /etc/my.cnf
1 # For advice on how to change settings please see
2 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
3 [client]
4 socket=/mysqldata/mysql/mysql.sock
5
6 [mysqld]
7 #
8 # Remove leading # and set to the amount of RAM for the most important data
9 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
10 # innodb_buffer_pool_size = 128M
11 #
12 # Remove leading # to turn on a very important data integrity option: logging
13 # changes to the binary log between backups.
14 # log_bin
15 #
16 # Remove leading # to set options mainly useful for reporting servers.
17 # The server defaults are faster for transactions and fast SELECTs.
18 # Adjust sizes as needed, experiment to find the optimal values.
19 # join_buffer_size = 128M
20 # sort_buffer_size = 2M
21 # read_rnd_buffer_size = 2M
22 datadir=/mysqldata/mysql
23 socket=/mysqldata/mysql/mysql.sock
24 server-id = 1 **//添加**
25 log_bin=/mysqldata/log_bin.00001
26
27 # Disabling symbolic-links is recommended to prevent assorted security risks
28 symbolic-links=0
29
30 log-error=/var/log/mysqld.log
31 pid-file=/var/run/mysqld/mysqld.pid
#再次启动mysql
[root@linux_64 mysqldata]# service mysqld start
Starting mysqld: [ OK ]
[root@linux_64 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.25-log MySQL Community Server (GPL)
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> select version();
±-----------+
| version() |
±-----------+
| 5.7.25-log |
±-----------+
1 row in set (0.00 sec)
mysql> show variables like’%log_bin%’;
±--------------------------------±-------------------------+
| Variable_name | Value |
±--------------------------------±-------------------------+
| log_bin | ON |
| log_bin_basename | /mysqldata/log_bin |
| log_bin_index | /mysqldata/log_bin.index |
| log_bin_trust_function_creators | OFF |
| log_bin_use_v1_row_events | OFF |
| sql_log_bin | ON |
±--------------------------------±-------------------------+
6 rows in set (0.00 sec)